Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
// Lightweight throwaway scenario used by {@link warmUpCodexModel} to pre-pay
// the Codex session cold-start cost (native codex app-server spawn + model
// list resolution) before the real assertion runs.
const
CODEX_WARMUP_SCENARIO_ID
=
'smoke-hello-codex-warmup'
;
const
CODEX_WARMUP_REPLY
=
'MOCKED_CODEX_WARMUP_RESPONSE'
;
const
AGENT_HOST_SCENARIO_ID
=
'smoke-hello-agent-host'
;
const
AGENT_HOST_REPLY
=
'MOCKED_AGENT_HOST_RESPONSE'
;
const
AGENT_HOST_MODEL
=
'gpt-5.3-codex'
;
const
AGENT_HOST_SANDBOX_SCENARIO_ID
=
'smoke-hello-agent-host-sandbox'
;
const
AGENT_HOST_SANDBOX_REPLY
=
'MOCKED_AGENT_HOST_SANDBOX_RESPONSE'
;
const
AGENT_HOST_SDK_SANDBOX_SCENARIO_ID
=
'smoke-hello-agent-host-sdk-sandbox'
;
const
AGENT_HOST_SDK_SANDBOX_REPLY
=
'MOCKED_AGENT_HOST_SDK_SANDBOX_RESPONSE'
;
// Lightweight throwaway scenario used by {@link warmUpAgentHostModel} to
// prime the CLI model list before the real assertion. Registered in every
// AgentHost suite by {@link setupAgentHostSuite}.
const
AGENT_HOST_WARMUP_SCENARIO_ID
=
'smoke-hello-agent-host-warmup'
;
const
AGENT_HOST_WARMUP_REPLY
=
'MOCKED_AGENT_HOST_WARMUP_RESPONSE'
;
export
function
setup
(
:
)
{
describe
(
'Agents Window (local AgentHost)'
,
(
)
=>
{
const
=
setupAgentHostSuite
(
,
{
:
'AgentHost'
,
registerScenarios
:
(
{
,
}
)
=>
{
registerScenario
(
AGENT_HOST_SCENARIO_ID
,
new
ScenarioBuilder
(
)
.
emit
(
AGENT_HOST_REPLY
)
.
build
(
)
)
;
registerScenario
(
AGENT_HOST_SANDBOX_SCENARIO_ID
,
shellEchoScenario
(
AGENT_HOST_SANDBOX_REPLY
)
)
;
}
,
:
{
// AgentHost-side sandbox: customTerminalTool gates the AgentHost’s own
// shell tools (which honor chat.agent.sandbox.*), and chat.agent.sandbox.enabled
// turns the sandbox on for the auto-approve path used by the sandbox test.
'chat.agentHost.customTerminalTool.enabled'
:
true
,
'chat.agent.sandbox.enabled'
:
'on'
,
// CI macOS runners commonly resolve the default shell as /bin/sh, which
// exercises the sentinel-based completion parser path. Force the same
// profile on macOS so local runs cover the same branch.
...
(
.
===
'darwin'
?
{
'terminal.integrated.profiles.osx'
:
{
'Smoke AgentHost Sandbox sh'
:
{
:
'/bin/sh'
}
,
}
,
'terminal.integrated.defaultProfile.osx'
:
'Smoke AgentHost Sandbox sh'
,
}
:
{
}
)
,
}
,
}
)
;
it
(
'Test Copilot CLI session via AgentHost'
,
async
function
(
)
{
this
.
timeout
(
5
*
60
*
1000
)
;
const
=
this
.
as
;
try
{
await
warmUpAgentHostModel
(
,
,
'Agents Window (AgentHost)'
)
;
const
=
.
.
requestCount
(
)
;
await
.
.
.
submitNewSessionPrompt
(
`hello world [scenario:${AGENT_HOST_SCENARIO_ID}]`
)
;
const
=
await
.
.
.
waitForAssistantText
(
AGENT_HOST_REPLY
)
;
.
log
(
`Agents Window (AgentHost) response: ${text}`
)
;
.
ok
(
.
.
requestCount
(
)
>
,
'expected the mock LLM server to have received a new request from the AgentHost session'
)
;
// Confirm the request flowed through the AgentHost process (not
// the renderer-side Copilot Chat extension fallback) by checking
// for a `chat/turnStarted` frame in the AHP JSONL transcript.
// In the multi-chat protocol turns are dispatched as chat
// actions on the session's default chat channel. The transcript
// is written through an async queue (see AhpJsonlLogger), so the
// frame may not be on disk yet even after the assistant reply has
// rendered — poll briefly.
const
=
.
join
(
.
,
'ahp'
)
;
const
=
await
waitForLogContent
(
(
)
=>
readAhpFrames
(
)
,
'"type":"chat/turnStarted"'
)
;
.
ok
(
.
includes
(
'"type":"chat/turnStarted"'
)
,
`expected the AgentHost process to have received a chat/turnStarted dispatchAction (checked ${ahpJsonlFiles(ahpLogDir).length} jsonl files under ${ahpLogDir}); if missing, the renderer-side extension likely served the reply instead`
// Register the Codex provider in the agent host process (it is
// off by default). The provider resolves the codex SDK from the
// repo's `node_modules` in dev, or `product.agentSdks.codex` in
// packaged builds (or the VSCODE_AGENT_HOST_CODEX_SDK_ROOT
// override) — so the test below is a hard requirement in dev and
// skips only in built products where the SDK is genuinely absent.
'chat.agentHost.codexAgent.enabled'
:
true
,
}
,
}
)
;
it
(
'Test Codex session'
,
async
function
(
)
{
this
.
timeout
(
5
*
60
*
1000
)
;
const
=
this
.
as
;
// Resolve Codex availability OUTSIDE the try/catch below so that the
// Pending thrown by `this.skip()` is not swallowed (and re-thrown as a
// failure) by the failure-diagnostics handler.
await
.
.
.
startNewSession
(
)
;
const
=
await
.
.
.
isSessionTypeAvailable
(
'Codex'
)
;
if
(
!
)
{
// Codex must be available — and so this test must run rather than
// skip — whenever the build under test is supposed to be able to
// resolve the SDK:
// - Running from source (VSCODE_DEV=1, set by the smoke runner
// when no `--build` is passed): the agent host is not built, so
// it resolves the SDK from the repo's `node_modules`
// (`@openai/codex` is a devDependency).
// - Publish builds: `product.agentSdks.codex` is stamped (only
// when VSCODE_PUBLISH=true, see build/azure-pipelines/common/
// agent-sdk-produce.yml) so the SDK is fetched from the CDN.
// In both cases an unavailable Codex is a regression — fail loudly.
// Otherwise (built non-publish CI, where the SDK is neither shipped
// nor stamped) Codex is legitimately absent, so skip gracefully.
//
// VSCODE_DEV (not app.quality === Quality.Dev) is the precise
// "from source" signal: parseQuality() also returns Quality.Dev for
// a `--build` product when VSCODE_QUALITY is unset, which would
// wrongly hard-fail a packaged build that legitimately lacks Codex.
const
=
.
[
'VSCODE_DEV'
]
===
'1'
;
const
=
(
.
[
'VSCODE_PUBLISH'
]
??
''
)
.
toLowerCase
(
)
===
'true'
;
if
(
||
)
{
throw
new
Error
(
`[Agents Window/Codex] Codex session type unexpectedly unavailable (VSCODE_DEV=${process.env['VSCODE_DEV']??'<unset>'}, VSCODE_PUBLISH=${process.env['VSCODE_PUBLISH']??'<unset>'}) — the SDK should be resolvable from node_modules (from source) or product.agentSdks.codex (publish build)`
)
;
}
.
log
(
'[Agents Window/Codex] Codex session type not available in this built product (no product.agentSdks.codex); skipping'
)
;
this
.
skip
(
)
;
}
// Codex reports as "available" once the `@openai/codex` launcher shim
// resolves, but the native binary ships as a separate per-platform
// optional dependency that npm silently skips when its install fails.
// A stale `node_modules` cache can thus have the shim but no binary, so
// fail fast here (from source) instead of timing out at spawn time.
// vendor dir (or the whole platform package) is missing → treated as not found
}
if
(
!
)
{
throw
new
Error
(
`[Agents Window/Codex] Codex native binary missing at ${platformPkgDir}. We depend on \`@openai/codex\`, which is only a thin launcher shim; the actual native binaries ship as its per-platform optional dependencies (\`@openai/codex-<platform>-<arch>\`). \`npm install\` does not fail when an optional dependency can't be installed, so node_modules can end up with the shim but no binary — Codex then reports as "available" but has nothing to spawn. Try bumping build/.cachesalt to force a fresh \`npm ci\` that reinstalls the binary.`
)
;
}
}
try
{
// Pre-pay the Codex session cold-start cost: the first Codex session
// in a fresh agent host has to spawn the native codex app-server and
// resolve its model list before the first /responses request can
// complete. A throwaway prompt absorbs that so the real assertion
`expected the mock LLM server to have received a new request from the Codex session (before=${requestsBefore}, after=${codex.mockServer.requestCount()})`
)
;
// Confirm the request flowed through the AgentHost process (the codex
// harness) and not a renderer-side fallback by checking for a
// `chat/turnStarted` frame in the AHP JSONL transcript. The transcript
// is written through an async queue, so poll briefly.
const
=
.
join
(
.
,
'ahp'
)
;
const
=
await
waitForLogContent
(
(
)
=>
readAhpFrames
(
)
,
'"type":"chat/turnStarted"'
)
;
.
ok
(
.
includes
(
'"type":"chat/turnStarted"'
)
,
`expected the AgentHost process to have received a chat/turnStarted dispatchAction (checked ${ahpJsonlFiles(ahpLogDir).length} jsonl files under ${ahpLogDir}); if missing, the renderer-side extension likely served the reply instead`
/**
* Primes a freshly-spawned AgentHost process's CLI model list to avoid the
* cold-start "No model available" race (github/copilot-agent-runtime#9876):
* the very first query in the process lifetime can reach the CLI before its
* model list has resolved, surfacing as a `session/error`. A throwaway
* session resolves it because the model list is cached by then.
*
* Assumes the Agents Window is showing a new-session view. Sends a throwaway
* prompt, ignores its outcome, then leaves a fresh new-session view with
* Agent Host Copilot selected so the caller can submit the real prompt
* against an already-warmed model list.
*/
async
function
warmUpAgentHostModel
(
:
,
:
,
:
string
)
:
Promise
<
void
>
{
await
.
.
.
waitForNewSessionView
(
)
;
await
.
.
.
selectSessionType
(
'Copilot'
)
;
await
.
.
.
submitNewSessionPrompt
(
`hello world [scenario:${AGENT_HOST_WARMUP_SCENARIO_ID}]`
)
;
try
{
await
.
.
.
waitForAssistantText
(
AGENT_HOST_WARMUP_REPLY
,
30_000
)
;
}
catch
(
)
{
// Ignore — the warm-up itself may hit the cold-start race; the caller's
// real attempt runs against an already-warmed model list.
.
log
(
`${label} warm-up attempt did not produce the expected reply (likely the cold-start race); proceeding with the real attempt. Reason: ${error instanceofError? error.message :String(error)}`
)
;
}
await
.
.
.
startNewSession
(
)
;
await
.
.
.
waitForNewSessionView
(
)
;
await
.
.
.
selectSessionType
(
'Copilot'
)
;
}
/**
* Pre-pays the Codex session cold-start cost: the first Codex session in a
* fresh agent host has to spawn the native `codex app-server` binary and
* resolve its model list before the first `/responses` request can complete.
*
* Assumes the Agents Window is showing a new-session view AND that the 'Codex'
* session type is available (callers gate on
* {@link AgentsWindow.isSessionTypeAvailable} first). Sends a throwaway prompt
* to a 'Codex' session, ignores its outcome (the warm-up itself may hit the
* cold start), then leaves a fresh new-session view with 'Codex' selected so
* the caller can submit the real prompt against a warm pipeline.
*/
async
function
warmUpCodexModel
(
:
,
:
,
:
string
)
:
Promise
<
void
>
{
await
.
.
.
waitForNewSessionView
(
)
;
await
.
.
.
selectSessionType
(
'Codex'
)
;
await
.
.
.
submitNewSessionPrompt
(
`hello world [scenario:${CODEX_WARMUP_SCENARIO_ID}]`
)
;
try
{
await
.
.
.
waitForAssistantText
(
CODEX_WARMUP_REPLY
,
60_000
)
;
}
catch
(
)
{
// Ignore — the warm-up itself may hit the cold-start race; the caller's
// real attempt runs against an already-warmed pipeline.
.
log
(
`${label} warm-up attempt did not produce the expected reply (likely the cold-start race); proceeding with the real attempt. Reason: ${error instanceofError? error.message :String(error)}`
)
;
}
await
.
.
.
startNewSession
(
)
;
await
.
.
.
waitForNewSessionView
(
)
;
await
.
.
.
selectSessionType
(
'Codex'
)
;
}
/**
* Accessors for the per-suite state owned by {@link setupAgentHostSuite}.
* Implemented with getters so tests read the values populated by the
* `before` hooks (which run after the suite body registers the tests).
*/
interface
IAgentHostSuiteContext
{
readonly
:
;
readonly
:
string
;
}
/**
* Installs the shared `before`/`after` hooks for a "local AgentHost" smoke
* suite: starts the mock LLM server, creates the app with the AgentHost env
* vars, pre-seeds `settings.json` into both the default and Agents profiles,
* and opens the workspace folder in the Agents Window.
*
* The only per-suite differences are the registered scenarios and the
* sandbox-related settings overlay, so those are passed in.
*/
function
setupAgentHostSuite
(
:
,
:
{
readonly
:
string
;
readonly
registerScenarios
:
(
:
{
:
any
;
registerScenario
:
(
:
string
,
:
unknown
)
=>
void
}
)
=>
void
;
readonly
:
<
string
,
unknown
>
;
}
)
:
{
let
:
;
let
:
string
;
before
(
async
function
(
)
{
const
{
,
,
}
=
require
(
getMockLlmServerPath
(
)
)
;
registerScenario
(
'text-only'
,
new
ScenarioBuilder
(
)
.
emit
(
'OK'
)
.
build
(
)
)
;
registerScenario
(
AGENT_HOST_WARMUP_SCENARIO_ID
,
new
ScenarioBuilder
(
)
.
emit
(
AGENT_HOST_WARMUP_REPLY
)
.
build
(
)
)
;
.
registerScenarios
(
{
,
}
)
;
=
await
startServer
(
0
,
mockServerStartOptions
(
(
:
string
)
=>
.
log
(
)
)
)
;
.
log
(
`Mock LLM server (${config.serverLabel}) started at ${getMockLlmServerUrl(mockServer)}`
)
;
}
)
;
installDiagnosticsHandler
(
)
;
before
(
async
function
(
)
{
const
=
this
.
?.
?.
??
'unknown'
;
const
:
=
{
...
this
.
,
:
suiteLogsPath
(
this
.
,
)
,
:
suiteCrashPath
(
this
.
,
)
,
}
;
=
.
;
this
.
=
createApp
(
,
=>
(
{
...
,
:
{
...
(
.
??
{
}
)
,
...
getCopilotSmokeTestEnv
(
,
{
:
.
}
)
,
COPILOT_API_URL
:
getMockLlmServerUrl
(
)
,
COPILOT_DEBUG_GITHUB_API_URL
:
getMockLlmServerUrl
(
)
,
GITHUB_COPILOT_API_TOKEN
:
'smoketest-fake-agent-host-token'
,
// Route the agent host's shared CAPI client (used by the Codex /
// agent-host harnesses for model discovery + requests) at the mock
// instead of api.github.com, which would 401 with the fake token.
VSCODE_AGENT_HOST_CAPI_URL_OVERRIDE
:
getMockLlmServerUrl
(
)
,
}
,
}
)
)
;
// Pre-seed settings.json on disk into BOTH the default profile and the
// Agents profile so Agent Host startup observes the test configuration.
const
=
(
this
.
as
)
.
;
if
(
)
{
const
=
JSON
.
stringify
(
{
'github.copilot.advanced.debug.overrideProxyUrl'
:
getMockLlmServerUrl
(
)
,
// AgentHost's fetch patch honors PAC/system proxy resolution only
// when proxy support is enabled. The smoke profile is pre-seeded from
// scratch, so set the production default explicitly rather than
// relying on configuration registration timing.
'http.proxySupport'
:
'override'
,
'chat.allowAnonymousAccess'
:
true
,
'github.copilot.chat.githubMcpServer.enabled'
:
false
,
'chat.agentHost.ahpJsonlLoggingEnabled'
:
true
,
'chat.agentHost.unsafeTestToken'
:
'smoketest-fake-agent-host-token'
,
// Verbose Copilot runtime logging for capturable failure diagnostics.
'chat.agentHost.copilotSdk.logLevel'
:
'trace'
,
// These suites exercise Agent Host and sandbox behavior, not Auto routing.
'chat.defaultModel'
:
AGENT_HOST_MODEL
,
...
.
,
}
,
null
,
2
)
;
for
(
const
of
[
.
join
(
,
'User'
,
'settings.json'
)
,
.
join
(
,
'User'
,
'profiles'
,
'builtin'
,
'agents'
,
'settings.json'
)
,
]
)
{
.
mkdirSync
(
.
dirname
(
)
,
{
:
true
}
)
;
.
writeFileSync
(
,
)
;
}
}
await
(
this
.
as
)
.
start
(
)
;
}
)
;
installAppAfterHandler
(
)
;
before
(
async
function
(
)
{
const
=
this
.
as
;
.
execSync
(
'git checkout . --quiet'
,
{
:
.
}
)
;
const
=
.
.
.
getAllWindows
(
)
.
;
await
.
.
.
openCurrentFolderInAgentsWindow
(
)
;
await
.
.
.
switchToAgentsWindow
(
)
;
}
)
;
after
(
async
function
(
)
{
if
(
)
{
await
.
close
(
)
;
}
}
)
;
return
{
get
mockServer
(
)
{
return
;
}
,
get
logsPath
(
)
{
return
;
}
,
}
;
}
/**
* Polls `readContent` until it returns a string matching `matcher` or the
* timeout elapses, then returns the last content read. Log files in these
* suites are written through async queues (e.g. AhpJsonlLogger), so an entry
* may not be on disk yet even after the assistant reply has rendered.
*/
async
function
waitForLogContent
(
readContent
:
(
)
=>
string
,
:
|
string
,
=
5_000
)
:
Promise
<
string
>
{
const
matches
=
(
:
string
)
=>
typeof
===
'string'
?
.
includes
(
)
:
.
test
(
)
;
const
=
.
now
(
)
+
;
let
=
readContent
(
)
;
while
(
!
matches
(
)
&&
.
now
(
)
<
)
{
await
new
Promise
(
=>
setTimeout
(
,
100
)
)
;
=
readContent
(
)
;
}
return
;
}
/** Reads a file, returning '' if it does not exist yet. */
function
readFileIfExists
(
:
string
)
:
string
{
return
.
existsSync
(
)
?
.
readFileSync
(
,
'utf8'
)
:
''
;
}
/** Lists the `.jsonl` transcript files in an AHP log directory. */
function
ahpJsonlFiles
(
:
string
)
:
string
[
]
{
return
.
existsSync
(
)
?
.
readdirSync
(
)
.
filter
(
=>
.
endsWith
(
'.jsonl'
)
)
:
[
]
;
}
/** Concatenates every AHP JSONL transcript in `ahpLogDir` into one string. */