Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
/**
* The downloader defaults to "SDK already on disk", which is what makes these
* tests deterministic — otherwise the answer depends on whether the machine
* running the suite has `@openai/codex` in `node_modules`. Tests wanting the
* cold case override `_isSdkResolvableWithoutDownload` directly.
*/
function
createAgentContext
(
:
<
,
'add'
>
,
models
:
(
)
=>
Promise
<
[
]
>
,
:
<
string
,
boolean
>
=
{
}
,
=
new
RecordingAgentSdkDownloader
(
)
)
:
{
const
=
new
TestInstantiationService
(
)
;
const
=
new
NullLogService
(
)
;
const
=
.
add
(
new
AgentHostStateManager
(
)
)
;
const
=
.
add
(
new
AgentConfigurationService
(
,
)
)
;
.
updateRootConfig
(
)
;
.
stub
(
,
{
:
undefined
}
)
;
.
stub
(
,
{
:
undefined
,
}
)
;
.
stub
(
,
{
:
undefined
}
)
;
.
stub
(
,
)
;
.
stub
(
,
new
NullAgentHostWorktreeIsolation
(
)
)
;
.
stub
(
,
createNoopCustomizationEnablementService
(
)
)
;
.
stub
(
,
createTestGitHubEndpointService
(
)
)
;
.
stub
(
,
createTestAgentHostProxyResolver
(
)
)
;
.
stub
(
,
)
;
.
stub
(
,
NULL_CHECKPOINT_SERVICE
)
;
.
stub
(
,
{
:
undefined
,
getNativeSdkTelemetryConfig
:
async
(
)
=>
undefined
}
)
;
.
stub
(
,
{
:
undefined
,
:
.
}
)
;
.
stub
(
,
{
:
undefined
,
:
'1.0.0-test'
}
as
)
;
.
stub
(
,
{
:
URI
.
file
(
'/tmp'
)
}
)
;
.
stub
(
,
)
;
const
=
.
add
(
.
createInstance
(
)
)
;
const
=
[
'_probeAccountAtStartup'
]
.
bind
(
)
;
[
'_probeAccountAtStartup'
]
=
async
(
)
=>
{
}
;
return
{
,
,
,
,
}
;
}
function
createAgent
(
:
<
,
'add'
>
,
models
:
(
)
=>
Promise
<
[
]
>
,
:
<
string
,
boolean
>
=
{
}
,
=
new
RecordingAgentSdkDownloader
(
)
)
:
{
return
createAgentContext
(
,
,
,
)
.
;
}
const
=
{
:
[
{
:
'gpt-5.6-sol'
,
:
'gpt-5.6-sol'
,
:
null
,
:
null
,
:
null
,
:
'GPT-5.6-Sol'
,
:
'Latest frontier agentic coding model.'
,
:
false
,
:
[
{
:
'low'
,
:
'Fast responses with lighter reasoning'
}
,
{
:
'medium'
,
:
'Balances speed and reasoning depth for everyday tasks'
}
,
{
:
'high'
,
:
'Greater reasoning depth for complex problems'
}
,
{
:
'xhigh'
,
:
'Extra high reasoning depth for complex problems'
}
,
{
:
'max'
,
:
'Maximum reasoning depth for the hardest problems'
}
,
{
:
'ultra'
,
:
'Maximum reasoning with automatic task delegation'
}
,
]
,
:
'low'
,
:
[
'text'
,
'image'
]
,
:
true
,
:
[
]
,
:
[
]
,
:
null
,
:
true
,
}
]
,
:
null
,
}
;
/**
* @paramrequests records every method the agent asks for, so a test can assert
* on enumeration specifically — `config/read` shares this connection once the
* SDK is local, so a raw "did we connect" count conflates callers.
*/
function
createChatGPTConnection
(
:
unknown
=
{
:
'chatgpt'
,
:
'person@example.com'
,
:
'plus'
}
,
:
string
[
]
=
[
]
)
{
return
{
:
'ready'
,
:
{
request
:
async
(
:
string
)
=>
{
.
push
(
)
;
if
(
===
'account/read'
)
{
return
{
,
:
true
}
;
}
if
(
===
'config/read'
)
{
return
{
:
{
:
'openai'
}
}
;
}
if
(
===
'model/list'
)
{
return
;
}
throw
new
Error
(
`Unexpected request: ${method}`
)
;
}
,
}
,
:
{
dispose
(
)
{
}
}
,
:
{
kill
:
(
)
=>
true
}
,
}
;
}
suite
(
'CodexAgent model refresh'
,
(
)
=>
{
const
=
ensureNoDisposablesAreLeakedInTestSuite
(
)
;
test
(
'keeps the persistent app-server stopped until a Codex session is selected'
,
async
(
)
=>
{
const
=
createAgent
(
,
async
(
)
=>
[
]
,
{
[
.
]
:
true
}
)
;
const
:
string
[
]
=
[
]
;
const
=
createChatGPTConnection
(
undefined
,
)
;
let
=
false
;
[
'_ensureConnection'
]
=
async
(
)
=>
{
=
true
;
[
'_connection'
]
=
as
never
;
return
as
never
;
}
;
// These are all ambient registration/startup paths in AgentService. None is
// an affirmative choice to use Codex.
const
=
.
onDidDiscoverChats
(
(
)
=>
{
}
)
;
const
=
await
.
listChatsToMigrate
(
)
;
const
=
.
uri
(
'codex'
,
'existing-session'
)
;
const
=
await
.
getChatMetadata
(
URI
.
parse
(
buildDefaultChatUri
(
)
)
,
)
;
await
.
authenticate
(
.
getProtectedResources
(
)
[
0
]
.
,
'token-replayed-at-registration'
)
;
await
new
Promise<void>
(
=>
setTimeout
(
,
0
)
)
;
.
dispose
(
)
;
.
deepStrictEqual
(
{
,
,
,
:
.
.
get
(
)
}
,
{
:
false
,
:
undefined
,
:
[
]
,
:
[
]
,
}
)
;
// Even an ambient catalog refresh must not cross the session boundary.
await
.
refreshModels
(
)
;
.
strictEqual
(
,
false
)
;
// Session creation/restoration crosses the activation boundary; its catalog
// refresh may now retain the app-server connection.
[
'_activate'
]
(
)
;
await
.
refreshModels
(
)
;
.
deepStrictEqual
(
{
,
// One enumeration, not one per caller that happened to want the connection.
:
.
filter
(
=>
===
'model/list'
)
.
,
:
.
.
get
(
)
.
map
(
=>
(
{
:
.
,
:
.
,
:
.
,
:
.
}
)
)
,
}
,
{
:
true
,
:
1
,
:
[
{
:
'codex'
,
:
toCodexModelSelectionId
(
'openai'
,
'gpt-5.6-sol'
)
,
:
'GPT-5.6-Sol'
,
:
{
:
'chatgptSubscription'
,
:
'chatgpt'
}
,
}
]
,
}
)
;
}
)
;
test
(
'restored model waits for an authentication refresh queued behind activation'
,
async
(
)
=>
{
const
=
[
{
:
'copilot-model'
,
:
'Copilot Model'
,
:
[
'/responses'
]
}
]
as
[
]
;
const
=
new
DeferredPromise<void>
(
)
;
const
=
new
DeferredPromise<void>
(
)
;
const
=
new
DeferredPromise<void>
(
)
;
const
=
new
DeferredPromise<void>
(
)
;
let
=
0
;
const
=
createAgent
(
,
async
(
)
=>
{
++
;
await
.
complete
(
)
;
await
.
;
return
;
}
)
;
[
'_refreshProviderConfiguration'
]
=
async
(
)
=>
{
}
;
[
'_resolveGitHubMcpServerConfiguration'
]
=
async
(
)
=>
undefined
;
let
=
0
;
[
'_refreshCodexModels'
]
=
async
(
)
=>
{
++
;
if
(
===
1
)
{
await
.
complete
(
)
;
await
.
;
}
return
false
;
}
;
[
'_activate'
]
(
)
;
await
.
;
const
=
{
:
toCodexModelSelectionId
(
'vscode-proxy'
,
'copilot-model'
)
}
;
const
=
{
:
}
;
const
=
[
'_resolveModel'
]
(
as
never
)
.
then
(
=>
(
{
,
:
undefined
}
)
,
=>
(
{
:
undefined
,
:
instanceof
Error
?
.
:
String
(
)
}
)
,
)
;
await
.
authenticate
(
.
getProtectedResources
(
)
[
0
]
.
,
'token'
)
;
await
.
complete
(
)
;
await
.
;
await
.
complete
(
)
;
.
deepStrictEqual
(
{
:
await
,
:
.
,
,
,
}
,
{
:
{
:
,
:
undefined
}
,
:
,
:
1
,
:
2
,
}
)
;
}
)
;
test
(
'model resolution starts discovery when the catalog is empty'
,
async
(
)
=>
{
const
=
[
{
:
'copilot-model'
,
:
'Copilot Model'
,
:
[
'/responses'
]
}
]
as
[
]
;
const
=
createAgent
(
,
async
(
)
=>
)
;
[
'_githubToken'
]
=
'token'
;
[
'_isSdkResolvableWithoutDownload'
]
=
async
(
)
=>
false
;
const
=
{
:
toCodexModelSelectionId
(
'vscode-proxy'
,
'copilot-model'
)
}
;
const
=
{
:
}
;
const
=
await
[
'_resolveModel'
]
(
as
never
)
;
.
deepStrictEqual
(
{
,
:
.
}
,
{
:
,
:
,
}
)
;
}
)
;
test
(
'queues a fresh model refresh when Codex activates during an ambient refresh'
'startup account probe tears down its one-off connection when account details stall'
,
async
(
)
=>
{
const
=
createAgentContext
(
,
async
(
)
=>
[
]
)
;
.
defineProperty
(
.
,
'_startupAccountProbeTimeoutMs'
,
{
:
5
}
)
;
const
:
string
[
]
=
[
]
;
const
=
new
DeferredPromise<void>
(
)
;
const
=
new
DeferredPromise<void>
(
)
;
const
=
new
DeferredPromise<void>
(
)
;
const
=
new
DeferredPromise<void>
(
)
;
.
[
'_startRawConnection'
]
=
async
(
)
=>
(
{
:
{
request
:
async
(
:
string
)
=>
{
if
(
===
'account/read'
)
{
return
{
:
{
:
'chatgpt'
,
:
'person@example.com'
,
:
'plus'
}
,
:
true
}
;
}
if
(
===
'account/rateLimits/read'
)
{
await
.
complete
(
)
;
await
.
;
return
{
:
{
:
null
,
:
null
}
,
:
null
,
:
null
}
;
}
if
(
===
'getAuthStatus'
)
{
await
.
complete
(
)
;
await
.
;
return
{
:
'chatgpt'
,
:
null
,
:
true
}
;
}
throw
new
Error
(
`Unexpected request: ${method}`
)
;
}
,
dispose
:
(
)
=>
{
.
push
(
'client'
)
;
}
,
}
,
:
{
dispose
:
(
)
=>
{
.
push
(
'proxy'
)
;
}
}
,
:
{
kill
:
(
)
=>
{
.
push
(
'child'
)
;
return
true
;
}
}
,
}
)
as
never
;
const
=
.
runStartupAccountProbe
(
)
;
await
Promise
.
all
(
[
.
,
.
]
)
;
await
;
.
deepStrictEqual
(
{
,
:
readCodexAccountInfo
(
.
.
)
,
:
.
[
'_connection'
]
.
,
}
,
{
:
[
'client'
,
'proxy'
,
'child'
]
,
:
{
:
'signedIn'
,
:
'person@example.com'
,
:
'plus'
,
:
undefined
,
:
true
,
:
undefined
,
:
undefined
,
:
undefined
,
}
,
:
'idle'
,
}
)
;
const
=
new
DeferredPromise<void>
(
)
;
const
=
{
request
:
async
(
:
string
)
=>
{
.
strictEqual
(
,
'account/read'
)
;
await
.
complete
(
undefined
)
;
return
{
:
null
,
:
true
}
;
}
,
}
;
.
[
'_connection'
]
=
{
:
'ready'
,
:
,
:
{
dispose
(
)
{
}
}
,
:
{
kill
:
(
)
=>
true
}
,
}
as
never
;
const
=
.
[
'_refreshAccount'
]
(
as
never
,
false
)
;
await
new
Promise<void>
(
=>
setImmediate
(
)
)
;
const
=
.
;
await
Promise
.
all
(
[
.
complete
(
)
,
.
complete
(
)
]
)
;
await
;
.
strictEqual
(
,
true
)
;
}
)
;
test
(
'startup account probe does not download a missing SDK'
,
async
(
)
=>
{
const
=
createAgentContext
(
,
async
(
)
=>
[
]
)
;
.
[
'_isSdkResolvableWithoutDownload'
]
=
async
(
)
=>
false
;
let
=
0
;
.
[
'_startRawConnection'
]
=
async
(
)
=>
{
++
;
throw
new
Error
(
'startup probe must not download'
)
;
}
;
await
.
runStartupAccountProbe
(
)
;
.
deepStrictEqual
(
{
,
:
readCodexAccountInfo
(
.
.
)
,
}
,
{
:
0
,
:
{
:
'unknown'
,
:
undefined
,
:
undefined
,
:
undefined
,
:
undefined
,
:
undefined
,
:
undefined
,
:
undefined
}
,
}
)
;
}
)
;
test
(
'standalone ChatGPT sign-in uses a temporary connection until login completes'
,
async
(
)
=>
{
const
=
createAgentContext
(
,
async
(
)
=>
[
]
)
;
const
:
string
[
]
=
[
]
;
const
:
string
[
]
=
[
]
;
let
=
false
;
let
:
(
(
:
{
:
string
|
null
;
:
boolean
;
:
string
|
null
}
)
=>
void
)
|
undefined
;
.
[
'_startRawConnection'
]
=
async
(
)
=>
(
{
:
{
:
.
,
request
:
async
(
:
string
)
=>
{
.
push
(
)
;
if
(
===
'account/read'
)
{
return
{
:
?
{
:
'chatgpt'
,
:
'person@example.com'
,
:
'plus'
}
:
null
,
:
true
}
;
}
if
(
===
'account/login/start'
)
{
queueMicrotask
(
(
)
=>
{
?.
(
{
:
'older-login'
,
:
true
,
:
null
}
)
;
}
)
;
setImmediate
(
(
)
=>
{
=
true
;
?.
(
{
:
'login-1'
,
:
true
,
:
null
}
)
;
}
)
;
return
{
:
'chatgpt'
,
:
'login-1'
,
:
'https://example.com/login'
}
;
}
if
(
===
'account/rateLimits/read'
)
{
return
{
:
{
:
null
,
:
null
}
,
:
null
,
:
null
}
;
}
if
(
===
'getAuthStatus'
)
{
return
{
:
'chatgpt'
,
:
null
,
:
true
}
;
}
throw
new
Error
(
`Unexpected request: ${method}`
)
;
}
,
onNotification
:
(
:
string
,
:
typeof
)
=>
{
=
;
return
{
dispose
(
)
{
}
}
;
}
,
dispose
:
(
)
=>
{
.
push
(
'client'
)
;
}
,
}
,
:
{
dispose
:
(
)
=>
{
.
push
(
'proxy'
)
;
}
}
,
:
{
kill
:
(
)
=>
{
.
push
(
'child'
)
;
return
true
;
}
}
,
}
)
as
never
;
await
.
[
'_signInToChatGPT'
]
(
'request-1'
)
;
.
deepStrictEqual
(
{
,
,
:
readCodexAccountInfo
(
.
.
)
,
:
.
[
'_connection'
]
.
,
}
,
{
:
[
'account/read'
,
'account/login/start'
,
'account/read'
,
'account/rateLimits/read'
,
'getAuthStatus'
]
,
:
[
'client'
,
'proxy'
,
'child'
]
,
:
{
:
'signedIn'
,
:
'person@example.com'
,
:
'plus'
,
:
undefined
,
:
true
,
:
undefined
,
:
undefined
,
:
undefined
}
,
:
'idle'
,
}
)
;
}
)
;
test
(
'persistent sign-in does not republish an auth URL after an early login completion'
,
async
(
)
=>
{
const
=
createAgentContext
(
,
async
(
)
=>
[
]
)
;
const
:
string
[
]
=
[
]
;
const
=
{
request
:
async
(
:
string
)
=>
{
.
push
(
)
;
if
(
===
'account/read'
)
{
return
{
:
null
,
:
true
}
;
}
if
(
===
'account/login/start'
)
{
// Model the persistent connection's global completion handler
// winning the race against this request's response.
.
[
'_setOpenAIAccountState'
]
(
{
:
'openai'
,
:
'signedIn'
,
:
'chatgpt'
,
:
'person@example.com'
,
:
'plus'
,
:
true
,
}
)
;
return
{
:
'chatgpt'
,
:
'login-early'
,
:
'https://example.com/obsolete-login'
}
;
}
throw
new
Error
(
`Unexpected request: ${method}`
)
;
}
,
}
;
.
[
'_connection'
]
=
{
:
'ready'
,
,
:
{
dispose
(
)
{
}
}
,
:
{
kill
:
(
)
=>
true
}
,
}
as
never
;
await
.
[
'_signInToChatGPT'
]
(
'request-early'
)
;
.
deepStrictEqual
(
{
,
:
readCodexAccountInfo
(
.
.
)
,
}
,
{
:
[
'account/read'
,
'account/login/start'
]
,
:
{
:
'signedIn'
,
:
'person@example.com'
,
:
'plus'
,
:
undefined
,
:
true
,
:
undefined
,
:
undefined
,
:
undefined
,
}
,
}
)
;
}
)
;
test
(
'shutdown cancels a one-off account connection that is still starting'
,
async
(
)
=>
{
const
=
createAgent
(
,
async
(
)
=>
[
]
)
;
await
[
'_startupAccountProbe'
]
.
complete
(
undefined
)
;
const
=
new
DeferredPromise<void>
(
)
;
const
=
new
DeferredPromise<void>
(
)
;
const
=
new
DeferredPromise<void>
(
)
;
const
:
string
[
]
=
[
]
;
const
=
{
:
{
dispose
:
(
)
=>
.
push
(
'client'
)
}
,
:
{
dispose
:
(
)
=>
.
push
(
'proxy'
)
}
,
:
{
kill
:
(
)
=>
{
.
push
(
'child'
)
;
return
true
;
}
}
,
}
;
[
'_startRawConnection'
]
=
(
async
(
?
:
number
,
?
:
)
=>
{
const
=
?.
onCancellationRequested
(
(
)
=>
{
.
.
dispose
(
)
;
.
.
dispose
(
)
;
.
.
kill
(
)
;
void
.
complete
(
)
;
}
)
;
await
.
complete
(
)
;
await
(
?
Promise
.
race
(
[
.
,
.
]
)
:
.
)
;
?.
dispose
(
)
;
if
(
?.
)
{
throw
new
Error
(
'start cancelled'
)
;
}
return
;
}
)
as
never
;
const
=
[
'_withOnDemandConnection'
]
(
async
(
)
=>
undefined
)
;
const
=
.
rejects
(
)
;
await
.
;
await
.
shutdown
(
)
;
const
=
[
...
]
;
await
.
complete
(
)
;
await
;
.
deepStrictEqual
(
,
[
'client'
,
'proxy'
,
'child'
]
)
;
}
)
;
test
(
'shutdown suppresses a local-SDK model refresh queued before shutdown'
,
async
(
)
=>
{
const
=
createAgent
(
,
async
(
)
=>
[
]
,
{
[
.
]
:
true
}
)
;
[
'_activated'
]
=
true
;
const
=
new
DeferredPromise<void>
(
)
;
const
=
new
DeferredPromise<void>
(
)
;
let
=
0
;
[
'_isSdkResolvableWithoutDownload'
]
=
async
(
)
=>
{
await
.
complete
(
undefined
)
;
await
.
;
return
true
;
}
;
.
refreshModels
=
async
(
)
=>
{
++
;
}
;
[
'_startModelRefreshWhenSdkIsLocal'
]
(
)
;
await
.
;
await
.
shutdown
(
)
;
await
.
complete
(
undefined
)
;
await
new
Promise<void>
(
=>
setImmediate
(
)
)
;
.
strictEqual
(
,
0
)
;
}
)
;
test
(
'shutdown suppresses chat discovery whose SDK check was already in flight'
,
async
(
)
=>
{
const
=
createAgent
(
,
async
(
)
=>
[
]
)
;
[
'_activated'
]
=
true
;
const
=
new
DeferredPromise<void>
(
)
;
const
=
new
DeferredPromise<void>
(
)
;
let
=
0
;
[
'_isSdkResolvableWithoutDownload'
]
=
async
(
)
=>
{
await
.
complete
(
undefined
)
;
await
.
;
return
true
;
}
;
[
'_emitCodexChats'
]
=
async
(
)
=>
{
++
;
return
true
;
}
;
const
=
[
'_startCodexChatDiscovery'
]
(
)
;
await
.
;
await
.
shutdown
(
)
;
await
.
complete
(
undefined
)
;
await
;
.
strictEqual
(
,
0
)
;
}
)
;
test
(
'does not enumerate at startup while signed-out use is disabled'
,
async
(
)
=>
{
const
=
createAgent
(
,
async
(
)
=>
[
]
,
{
}
)
;
const
:
string
[
]
=
[
]
;
[
'_ensureConnection'
]
=
async
(
)
=>
createChatGPTConnection
(
undefined
,
)
as
never
;
await
new
Promise<void>
(
=>
setTimeout
(
,
0
)
)
;
// Reading `config.toml` may still open a connection — that is unrelated to
// enumeration. What must not happen is asking about the account or catalog.
.
deepStrictEqual
(
{
:
.
filter
(
=>
===
'account/read'
||
===
'model/list'
)
,
:
.
.
get
(
)
,
}
,
{
:
[
]
,
:
[
]
,
}
)
;
}
)
;
test
(
'reports an empty catalog rather than downloading the SDK to enumerate'
,
async
(
)
=>
{
const
=
new
RecordingAgentSdkDownloader
(
false
)
;
const
=
createAgent
(
,
async
(
)
=>
[
]
,
{
[
.
]
:
true
}
,
)
;
let
=
0
;
[
'_isSdkResolvableWithoutDownload'
]
=
async
(
)
=>
false
;
[
'_ensureConnection'
]
=
async
(
)
=>
{
++
;
return
createChatGPTConnection
(
)
as
never
;
}
;
await
.
refreshModels
(
)
;
// The download is an explicit gesture now, so a refresh that finds no local
// SDK reports the honest empty catalog and leaves the offer to the banner.
.
deepStrictEqual
(
{
,
:
.
.
get
(
)
,
:
.
,
}
,
{
:
0
,
:
[
]
,
:
[
]
,
}
)
;
}
)
;
test
(
'never requires Copilot, whatever the flag says and whatever the account turns out to be'
,
async
(
)
=>
{
const
copilotRequired
=
(
:
)
=>
.
getProtectedResources
(
)
[
0
]
.
;
const
=
createAgent
(
,
async
(
)
=>
[
]
,
{
[
.
]
:
true
}
)
;
[
'_isSdkResolvableWithoutDownload'
]
=
async
(
)
=>
false
;
const
=
createAgent
(
,
async
(
)
=>
[
]
,
{
[
.
]
:
true
}
)
;
[
'_connection'
]
=
createChatGPTConnection
(
null
)
as
never
;
const
=
createAgent
(
,
async
(
)
=>
[
]
,
{
[
.
]
:
true
}
)
;
[
'_connection'
]
=
createChatGPTConnection
(
)
as
never
;
await
Promise
.
all
(
[
.
refreshModels
(
)
,
.
refreshModels
(
)
]
)
;
// `required: false` is unconditional: a `true` here from any of these
// combinations puts the whole Agents window behind a GitHub sign-in wall,
// because `resolveSignedOutWindowGate` forces sign-in only when *every*
// session type requires GitHub.
.
deepStrictEqual
(
{
:
copilotRequired
(
createAgent
(
,
async
(
)
=>
[
]
,
{
}
)
)
,
:
copilotRequired
(
)
,
:
copilotRequired
(
)
,
:
copilotRequired
(
)
,
}
,
{
:
false
,
:
false
,
:
false
,
:
false
,
}
)
;
}
)
;
test
(
'waits for an app-server already starting when signed-out use becomes enabled'
,
async
(
)
=>
{
const
=
createAgent
(
,
async
(
)
=>
[
]
,
{
}
)
;
const
=
createChatGPTConnection
(
)
;
let
!
:
(
)
=>
void
;
const
=
new
Promise<typeof connection>
(
=>
{
resolveConnection
=
(
)
=>
resolve
(
)
;
}
)
.
then
(
=>
{
[
'_connection'
]
=
as
never
;
return
;
}
)
;
[
'_connection'
]
=
{
:
'starting'
,
:
}
as
never
;
[
'_configurationService'
]
.
updateRootConfig
(
{
[
.
]
:
true
}
)
;
await
new
Promise<void>
(
=>
setTimeout
(
,
0
)
)
;
.
deepStrictEqual
(
.
.
get
(
)
,
[
]
)
;
resolveConnection
(
)
;
await
.
refreshModels
(
)
;
.
deepStrictEqual
(
.
.
get
(
)
.
map
(
=>
.
)
,
[
toCodexModelSelectionId
(
'openai'
,
'gpt-5.6-sol'
)
]
)
;
}
)
;
test
(
'publishes no ChatGPT models when the app server reports no account'
,
async
(
)
=>
{
const
=
[
{
:
'copilot-model'
,
:
'Copilot Model'
,
:
[
'/responses'
]
}
]
as
[
]
;
const
=
createAgent
(
,
async
(
)
=>
,
{
[
.
]
:
true
}
)
;
[
'_githubToken'
]
=
'token'
;
[
'_connection'
]
=
createChatGPTConnection
(
null
)
as
never
;
await
.
refreshModels
(
)
;
.
deepStrictEqual
(
{
:
.
.
get
(
)
.
map
(
=>
.
)
,
:
.
getProtectedResources
(
)
[
0
]
.
,
}
,
{
:
[
'codex'
]
,
:
false
,
}
)
;
}
)
;
test
(
'does not publish a model when authoritative discovery fails'
,
async
(
)
=>
{
const
=
createAgent
(
,
async
(
)
=>
[
]
,
{
[
.
]
:
true
}
)
;
[
'_connection'
]
=
{
:
'ready'
,
:
{
request
:
async
(
:
string
)
=>
{
if
(
===
'account/read'
)
{
return
{
:
{
:
'chatgpt'
,
:
null
,
:
'plus'
}
,
:
true
}
;
}
throw
new
Error
(
'model discovery failed'
)
;
}
,
}
,
:
{
dispose
(
)
{
}
}
,
:
{
kill
:
(
)
=>
true
}
,
}
as
never
;
await
.
refreshModels
(
)
;
.
deepStrictEqual
(
.
.
get
(
)
,
[
]
)
;
}
)
;
test
(
'keeps the last known-good models when a periodic refresh fails'
,
async
(
)
=>
{
let
=
false
;
const
=
[
{
:
'gpt-5.5'
,
:
'GPT-5.5'
,
:
[
'/responses'
]
}
]
as
[
]
;
const
=
createAgent
(
,
async
(
)
=>
{
if
(
)
{
throw
new
Error
(
'transient failure'
)
;
}
return
;
}
)
;
[
'_isSdkResolvableWithoutDownload'
]
=
async
(
)
=>
false
;
const
=
.
getProtectedResources
(
)
[
0
]
.
;
await
.
authenticate
(
,
'token'
)
;
await
.
refreshModels
(
)
;
=
true
;
await
.
refreshModels
(
)
;
.
deepStrictEqual
(
.
.
get
(
)
.
map
(
=>
.
)
,
[
toCodexModelSelectionId
(
'vscode-proxy'
,
'gpt-5.5'
)
]
)
;
}
)
;
test
(
'retries Copilot model discovery after a transient authentication refresh failure'
,
async
(
)
=>
{
let
=
0
;
const
=
[
{
:
'gpt-5.5'
,
:
'GPT-5.5'
,
:
[
'/responses'
]
}
]
as
[
]
;
const
=
createAgent
(
,
async
(
)
=>
{
++
;
if
(
===
1
)
{
throw
new
Error
(
'503 Service Unavailable'
)
;
}
return
;
}
)
;
[
'_isSdkResolvableWithoutDownload'
]
=
async
(
)
=>
false
;
.
defineProperties
(
,
{
:
{
:
1
}
,
:
{
:
1
}
,
}
)
;
await
.
authenticate
(
.
getProtectedResources
(
)
[
0
]
.
,
'token'
)
;
await
.
refreshModels
(
)
;
const
=
.
.
get
(
)
.
map
(
=>
.
)
;
await
waitForState
(
.
,
=>
.
>
0
)
;
.
deepStrictEqual
(
{
,
,
:
.
.
get
(
)
.
map
(
=>
.
)
,
}
,
{
:
2
,
:
[
]
,
:
[
toCodexModelSelectionId
(
'vscode-proxy'
,
'gpt-5.5'
)
]
,
}
)
;
}
)
;
test
(
'uses the reasoning efforts advertised by Copilot models'
,
async
(
)
=>
{
const
:
=
{
:
{
:
true
,
:
1
,
:
[
]
}
,
:
{
:
'gpt-5.6'
,
:
{
:
272_000
,
:
32_000
,
:
240_000
}
,
:
'model_capabilities'
,
:
{
:
true
,
:
true
,
:
true
,
:
true
}
,
:
'o200k_base'
,
:
'chat'
,
}
,
:
'gpt-5.6-sol'
,
:
true
,
:
false
,
:
'advanced'
,
:
true
,
:
'GPT-5.6-Sol'
,
:
'model'
,
:
{
:
'enabled'
,
:
''
}
,
:
false
,
:
[
'/responses'
]
,
:
'OpenAI'
,
:
'gpt-5.6-sol'
,
}
;
(
.
.
as
{
?
:
string
[
]
}
)
.
=
[
'none'
,
'low'
,
'medium'
,
'high'
,
'xhigh'
,
'max'
]
;
const
=
createAgent
(
,
async
(
)
=>
[
]
)
;
await
.
authenticate
(
.
getProtectedResources
(
)
[
0
]
.
,
'token'
)
;
await
.
refreshModels
(
)
;
.
deepStrictEqual
(
.
.
get
(
)
.
map
(
=>
(
{
:
.
,
:
.
?.
.
&&
{
enum
:
.
.
.
.
,
default
:
.
.
.
.
,
}
,
}
)
)
,
[
{
:
toCodexModelSelectionId
(
'vscode-proxy'
,
'gpt-5.6-sol'
)
,
:
{
enum
:
[
'none'
,
'low'
,
'medium'
,
'high'
,
'xhigh'
,
'max'
]
,
default
:
'medium'
,
}
,
}
]
)
;
}
)
;
test
(
'omits the thinking level when a Copilot model advertises no reasoning efforts'
,
async
(
)
=>
{
const
=
{
:
'gpt-5.5'
,
:
'GPT-5.5'
,
:
[
'/responses'
]
}
as
;
const
=
createAgent
(
,
async
(
)
=>
[
]
)
;
await
.
authenticate
(
.
getProtectedResources
(
)
[
0
]
.
,
'token'
)
;
await
.
refreshModels
(
)
;
.
strictEqual
(
.
.
get
(
)
[
0
]
.
,
undefined
)
;
}
)
;
test
(
'applies authentication received while the connection is starting to the proxy'
,
async
(
)
=>
{
const
=
createAgent
(
,
async
(
)
=>
[
]
)
;
[
'_queueModelRefresh'
]
=
async
(
)
=>
{
}
;
[
'_refreshProviderConfiguration'
]
=
async
(
)
=>
{
}
;
const
:
string
[
]
=
[
]
;
const
=
{
:
{
dispose
(
)
{
}
}
,
:
{
setToken
:
(
:
string
)
=>
.
push
(
)
,
dispose
(
)
{
}
,
}
,
:
{
kill
:
(
)
=>
true
}
,
}
;
let
!
:
(
:
typeof
)
=>
void
;
[
'_startConnection'
]
=
(
)
=>
new
Promise<typeof ready>
(
=>
=
)
as
never
;
const
=
[
'_ensureConnection'
]
(
)
;
await
.
authenticate
(
.
getProtectedResources
(
)
[
0
]
.
,
'token-arriving-during-start'
)
;
resolveStart
(
)
;
await
;
.
deepStrictEqual
(
,
[
'token-arriving-during-start'
]
)
;
}
)
;
test
(
'cancels an app-server that is still starting when shutdown begins'
,
async
(
)
=>
{
const
=
createAgent
(
,
async
(
)
=>
[
]
)
;
const
=
new
DeferredPromise<void>
(
)
;
const
=
new
DeferredPromise<void>
(
)
;
const
=
new
DeferredPromise<void>
(
)
;
const
:
string
[
]
=
[
]
;
const
=
{
:
{
dispose
:
(
)
=>
.
push
(
'client'
)
}
,
:
{
dispose
:
(
)
=>
.
push
(
'proxy'
)
}
,
:
{
kill
:
(
)
=>
{
.
push
(
'child'
)
;
return
true
;
}
}
,
}
;
[
'_startConnection'
]
=
(
async
(
:
number
,
?
:
)
=>
{
const
=
?.
onCancellationRequested
(
(
)
=>
{
.
.
dispose
(
)
;
.
.
dispose
(
)
;
.
.
kill
(
)
;
void
.
complete
(
)
;
}
)
;
await
.
complete
(
)
;
await
(
?
Promise
.
race
(
[
.
,
.
]
)
:
.
)
;
?.
dispose
(
)
;
if
(
?.
)
{
throw
new
Error
(
'start cancelled'
)
;
}
return
;
}
)
as
never
;
const
=
[
'_ensureConnection'
]
(
)
;
await
.
;
await
.
shutdown
(
)
;
const
=
[
...
]
;
await
.
complete
(
)
;
await
.
rejects
(
)
;
.
deepStrictEqual
(
,
[
'client'
,
'proxy'
,
'child'
]
)
;
}
)
;
test
(
'ignores a delayed connection-loss event from a replaced client'
,
(
)
=>
{
const
=
createAgent
(
,
async
(
)
=>
[
]
)
;
const
:
string
[
]
=
[
]
;
const
=
{
:
{
dispose
:
(
)
=>
.
push
(
'stale-client'
)
}
,
:
{
dispose
:
(
)
=>
.
push
(
'stale-proxy'
)
}
,
:
{
kill
:
(
)
=>
{
.
push
(
'stale-child'
)
;
return
true
;
}
}
,
}
;
const
=
{
:
{
dispose
:
(
)
=>
.
push
(
'current-client'
)
}
,
:
{
dispose
:
(
)
=>
.
push
(
'current-proxy'
)
}
,
:
{
kill
:
(
)
=>
{
.
push
(
'current-child'
)
;
return
true
;
}
}
,
}
;
[
'_connectionGeneration'
]
=
4
;
[
'_connection'
]
=
{
:
'ready'
,
...
}
as
never
;
// Both the generation and client identity protect the replacement: the
// first models a queued event from the prior generation; the second guards
// against a callback whose bookkeeping was stale but generation was not.
[
'_handleConnectionLost'
]
(
as
never
,
3
)
;
[
'_handleConnectionLost'
]
(
as
never
,
4
)
;
.
deepStrictEqual
(
{
:
[
'_isCurrentConnection'
]
(
as
never
)
,
,
}
,
{
:
true
,
:
[
]
,
}
)
;
}
)
;
test
(
'does not promote a connection that dies while startup is completing'
,
async
(
)
=>
{
const
=
createAgent
(
,
async
(
)
=>
[
]
)
;
const
:
string
[
]
=
[
]
;
[
'_startConnection'
]
=
async
=>
{
// Let `_ensureConnection` publish its `starting` state before simulating
// an exit in the narrow window before this promise resolves.
await
Promise
.
resolve
(
)
;
const
=
{
:
{
dispose
:
(
)
=>
.
push
(
'client'
)
}
,
:
{
dispose
:
(
)
=>
.
push
(
'proxy'
)
}
,
:
{
kill
:
(
)
=>
{
.
push
(
'child'
)
;
return
true
;
}
}
,
:
{
dispose
:
(
)
=>
.
push
(
'subscriptions'
)
}
,
}
;
[
'_handleConnectionLost'
]
(
as
never
,
)
;
return
as
never
;
}
;
await
.
rejects
(
[
'_ensureConnection'
]
(
)
,
/replaced while starting/
)
;
.
strictEqual
(
[
'_connection'
]
.
,
'idle'
)
;
.
deepStrictEqual
(
,
[
'subscriptions'
,
'client'
,
'proxy'
,
'child'
]
)
;
}
)
;
test
(
'rejects an app-server that exited before persistent listeners were attached'
,
async
(
)
=>
{
const
=
createAgent
(
,
async
(
)
=>
[
]
)
;
const
:
string
[
]
=
[
]
;
const
registration
=
(
)
=>
(
{
dispose
(
)
{
}
}
)
;
[
'_startRawConnection'
]
=
async
(
)
=>
(
{
:
{
:
.
,
:
.
,
:
,
:
,
dispose
:
(
)
=>
{
.
push
(
'client'
)
;
}
,
}
,
:
{
dispose
:
(
)
=>
{
.
push
(
'proxy'
)
;
}
}
,
:
{
:
1
,
:
null
,
kill
:
(
)
=>
{
.
push
(
'child'
)
;
return
false
;
}
,
}
,
}
)
as
never
;
await
.
rejects
(
[
'_startConnection'
]
(
0
,
.
)
,
/exited before persistent startup completed/
)
;
.
deepStrictEqual
(
,
[
'client'
,
'proxy'
,
'child'
]
)
;
}
)
;
test
(
'drops a model catalog returned by a replaced app-server'
,
async
(
)
=>
{
const
=
createAgent
(
,
async
(
)
=>
[
]
)
;
[
'_activated'
]
=
true
;
const
=
new
DeferredPromise<void>
(
)
;
const
=
new
DeferredPromise<void>
(
)
;
const
=
{
:
'ready'
,
:
{
request
:
async
(
:
string
)
=>
{
if
(
===
'account/read'
)
{
return
{
:
{
:
'chatgpt'
,
:
'old@example.com'
,
:
'plus'
}
,
:
true
}
;
}
if
(
===
'config/read'
)
{
return
{
:
{
:
'openai'
}
}
;
}
if
(
===
'model/list'
)
{
await
.
complete
(
)
;
await
.
;
return
;
}
throw
new
Error
(
`Unexpected request: ${method}`
)
;
}
,
}
,
:
{
dispose
(
)
{
}
}
,
:
{
kill
:
(
)
=>
true
}
,
}
;
[
'_connection'
]
=
as
never
;
const
=
[
'_refreshCodexModels'
]
(
)
;
await
.
;
const
=
[
{
:
'chatgpt'
,
:
toCodexModelSelectionId
(
'openai'
,
'current-model'
)
,
:
'Current Model'
,
:
false
}
]
;
[
'_codexModels'
]
=
;
[
'_connection'
]
=
createChatGPTConnection
(
)
as
never
;
await
.
complete
(
)
;
await
;
.
strictEqual
(
[
'_codexModels'
]
,
)
;
}
)
;
test
(
'drops provider configuration returned by a replaced app-server'
,
async
(
)
=>
{
const
=
createAgentContext
(
,
async
(
)
=>
[
]
)
;
.
[
'_activated'
]
=
true
;
const
=
new
DeferredPromise<void>
(
)
;
const
=
new
DeferredPromise<void>
(
)
;
.
[
'_connection'
]
=
{
:
'ready'
,
:
{
request
:
async
(
:
string
)
=>
{
.
strictEqual
(
,
'config/read'
)
;
await
.
complete
(
)
;
await
.
;
return
{
:
{
}
,
:
[
{
:
{
:
'user'
,
:
null
}
,
:
{
:
'friendly'
,
:
{
:
'always'
}
}
}
]
,
}
;
}
,
}
,
:
{
dispose
(
)
{
}
}
,
:
{
kill
:
(
)
=>
true
}
,
}
as
never
;
const
=
.
[
'_refreshProviderConfiguration'
]
(
)
;
await
.
;
.
[
'_connection'
]
=
createChatGPTConnection
(
)
as
never
;
await
.
complete
(
)
;
await
;
.
deepStrictEqual
(
{
:
.
[
'_providerConfigurationReady'
]
,
:
.
[
'_providerConfigurationValues'
]
,
}
,
{
:
false
,
:
{
}
,
}
)
;
}
)
;
test
(
'serializes account reads so later refreshes publish last'
,
async
(
)
=>
{
const
=
createAgent
(
,
async
(
)
=>
[
]
)
;
const
=
new
DeferredPromise<void>
(
)
;
const
=
new
DeferredPromise<void>
(
)
;
const
=
[
,
]
;
const
=
new
DeferredPromise<GetAccountResponse>
(
)
;
const
=
new
DeferredPromise<GetAccountResponse>
(
)
;
const
=
[
,
,
]
;
let
=
0
;
const
=
{
request
:
async
(
:
string
)
=>
{
.
strictEqual
(
,
'account/read'
)
;
const
=
++
;
await
[
]
.
complete
(
)
;
return
[
]
.
;
}
,
}
as
never
;
[
'_connection'
]
=
{
:
'ready'
,
,
:
{
dispose
(
)
{
}
}
,
:
{
kill
:
(
)
=>
true
}
,
}
as
never
;
const
=
[
'_refreshAccount'
]
(
,
false
)
;
const
=
[
'_refreshAccount'
]
(
,
false
)
;
await
.
;
.
strictEqual
(
,
1
)
;
await
.
complete
(
{
:
null
,
:
true
}
)
;
await
;
await
.
;
.
strictEqual
(
,
2
)
;
await
.
complete
(
{
:
{
:
'chatgpt'
,
:
'new@example.com'
,
:
'pro'
}
,
:
true
,
}
)
;
await
;
.
deepStrictEqual
(
[
'_openAIAccountState'
]
,
{
:
'openai'
,
:
'signedIn'
,
:
'chatgpt'
,
:
'new@example.com'
,
:
'pro'
,
:
true
,
}
)
;
}
)
;
test
(
'drops a thread catalog returned by a replaced app-server'
,
async
(
)
=>
{
const
=
createAgent
(
,
async
(
)
=>
[
]
)
;
const
=
new
DeferredPromise<void>
(
)
;
const
=
new
DeferredPromise<void>
(
)
;
const
=
{
:
'ready'
,
:
{
request
:
async
(
:
string
)
=>
{
.
strictEqual
(
,
'thread/list'
)
;
await
.
complete
(
)
;
await
.
;
return
{
:
[
]
,
:
null
}
;
}
,
}
,
:
{
dispose
(
)
{
}
}
,
:
{
kill
:
(
)
=>
true
}
,
}
;
[
'_connection'
]
=
as
never
;
const
=
[
'_listCodexChats'
]
(
)
;
await
.
;
[
'_connection'
]
=
createChatGPTConnection
(
)
as
never
;
await
.
complete
(
)
;
.
strictEqual
(
await
,
undefined
)
;
}
)
;
test
(
'keeps the newest rate-limit response when reads complete out of order'
,
async
(
)
=>
{
const
=
createAgent
(
,
async
(
)
=>
[
]
)
;
let
!
:
(
:
)
=>
void
;
let
!
:
(
:
)
=>
void
;
const
=
[
new
Promise<GetAccountRateLimitsResponse>
(
=>
=
)
,
new
Promise<GetAccountRateLimitsResponse>
(
=>
=
)
,
]
;
let
=
0
;
const
=
{
request
:
async
(
:
string
)
=>
{
.
strictEqual
(
,
'account/rateLimits/read'
)
;
return
[
++
]
;
}
,
}
as
never
;
[
'_connection'
]
=
{
:
'ready'
,
,
:
{
dispose
(
)
{
}
}
,
:
{
kill
:
(
)
=>
true
}
,
}
as
never
;
[
'_openAIAccountState'
]
=
{
:
'openai'
,
:
'signedIn'
,
:
'chatgpt'
,
:
'person@example.com'
,
:
'plus'
,
:
true
}
;
const
=
[
'_refreshAccountRateLimits'
]
(
,
'person@example.com'
)
;
const
=
[
'_refreshAccountRateLimits'
]
(
,
'person@example.com'
)
;
resolveSecond
(
{
:
{
:
null
,
:
null
,
:
{
:
20
,
:
300
,
:
200
}
,
:
null
,
:
null
,
:
null
,
:
null
,
:
null
,
:
null
}
,
:
null
,
:
null
,
}
)
;
await
;
resolveFirst
(
{
:
{
:
null
,
:
null
,
:
{
:
90
,
:
300
,
:
100
}
,
:
null
,
:
null
,
:
null
,
:
null
,
:
null
,
:
null
}
,
:
null
,
:
null
,
}
)
;
await
;
.
deepStrictEqual
(
[
'_openAIAccountRateLimit'
]
,
{
:
20
,
:
300
,
:
200
}
)
;
}
)
;
test
(
'surfaces current ChatGPT subscription models in the ChatGPT group'
,
async
(
)
=>
{
const
=
createAgent
(
,
async
(
)
=>
[
]
)
;
[
'_connection'
]
=
{
:
'ready'
,
:
{
request
:
async
(
:
string
)
=>
{
if
(
===
'account/read'
)
{
return
{
:
{
:
'chatgpt'
,
:
'person@example.com'
,
:
'plus'
}
,
:
true
}
;
}
if
(
===
'config/read'
)
{
return
{
:
{
:
'openai'
}
}
;
}
if
(
===
'model/list'
)
{
return
;
}
throw
new
Error
(
`Unexpected request: ${method}`
)
;
}
,
}
,
:
{
dispose
(
)
{
}
}
,
:
{
kill
:
(
)
=>
true
}
,
}
as
never
;
await
.
refreshModels
(
)
;
.
deepStrictEqual
(
.
.
get
(
)
.
map
(
=>
(
{
:
.
,
:
.
,
:
.
,
:
.
?.
.
&&
{
enum
:
.
.
.
.
,
default
:
.
.
.
.
,
}
,
:
.
,
}
)
)
,
[
{
:
'codex'
,
:
toCodexModelSelectionId
(
'openai'
,
'gpt-5.6-sol'
)
,
:
'GPT-5.6-Sol'
,
:
{
enum
:
[
'low'
,
'medium'
,
'high'
,
'xhigh'
,
'max'
,
'ultra'
]
,
default
:
'low'
,
}
,
:
{
:
'chatgptSubscription'
,
:
'chatgpt'
}
,
}
]
)
;
}
)
;
test
(
'omits the thinking level when a Codex model advertises no reasoning efforts'
,
async
(
)
=>
{
const
=
createAgent
(
,
async
(
)
=>
[
]
)
;
[
'_connection'
]
=
{
:
'ready'
,
:
{
request
:
async
(
:
string
)
=>
{
if
(
===
'account/read'
)
{
return
{
:
{
:
'chatgpt'
,
:
'person@example.com'
,
:
'plus'
}
,
:
true
}
;
}
if
(
===
'config/read'
)
{
return
{
:
{
:
'openai'
}
}
;
}
if
(
===
'model/list'
)
{
return
{
...
,
:
.
.
map
(
=>
(
{
...
,
:
[
]
}
)
)
,
}
;
}
throw
new
Error
(
`Unexpected request: ${method}`
)
;
}
,
}
,
:
{
dispose
(
)
{
}
}
,
:
{
kill
:
(
)
=>
true
}
,
}
as
never
;
await
.
refreshModels
(
)
;
.
strictEqual
(
.
.
get
(
)
[
0
]
.
,
undefined
)
;
}
)
;
test
(
'removes ChatGPT models when account/read reports signed out'
,
async
(
)
=>
{
const
=
createAgent
(
,
async
(
)
=>
[
]
)
;
[
'_codexModels'
]
=
[
{
:
'chatgpt'
,
:
toCodexModelSelectionId
(
'openai'
,
'gpt-5.6-sol'
)
,
:
'GPT-5.6-Sol'
,
:
true
}
]
;
[
'_connection'
]
=
{
:
'ready'
,
:
{
request
:
async
(
:
string
)
=>
{
.
strictEqual
(
,
'account/read'
)
;
return
{
:
null
,
:
true
}
;
}
,
}
,
:
{
dispose
(
)
{
}
}
,
:
{
kill
:
(
)
=>
true
}
,
}
as
never
;
await
[
'_refreshCodexModels'
]
(
)
;
.
deepStrictEqual
(
[
'_codexModels'
]
,
[
]
)
;
}
)
;
test
(
'keeps configured non-human providers out of the ChatGPT group'
,
async
(
)
=>
{
const
=
createAgent
(
,
async
(
)
=>
[
]
)
;
[
'_connection'
]
=
{
:
'ready'
,
:
{
request
:
async
(
:
string
)
=>
{
if
(
===
'account/read'
)
{
return
{
:
{
:
'apiKey'
}
,
:
true
}
;
}
if
(
===
'config/read'
)
{
return
{
:
{
:
'custom-provider'
}
}
;
}
if
(
===
'model/list'
)
{
return
;
}
throw
new
Error
(
`Unexpected request: ${method}`
)
;
}
,
}
,
:
{
dispose
(
)
{
}
}
,
:
{
kill
:
(
)
=>
true
}
,
}
as
never
;
await
[
'_refreshCodexModels'
]
(
)
;
.
deepStrictEqual
(
[
'_codexModels'
]
.
map
(
=>
(
{
:
.
,
:
.
,
:
.
}
)
)
,
[
{
:
'codex'
,
:
toCodexModelSelectionId
(
'custom-provider'
,
'gpt-5.6-sol'
)
,
:
{
:
'custom-provider'
}
,
}
]
)
;
}
)
;
test
(
'does not treat a custom provider named chatgpt as a ChatGPT subscription'
,
async
(
)
=>
{
const
=
createAgent
(
,
async
(
)
=>
[
]
)
;
[
'_connection'
]
=
{
:
'ready'
,
:
{
request
:
async
(
:
string
)
=>
{
if
(
===
'account/read'
)
{
return
{
:
{
:
'apiKey'
}
,
:
false
}
;
}
if
(
===
'config/read'
)
{
return
{
:
{
:
'chatgpt'
}
}
;
}
if
(
===
'model/list'
)
{
return
;
}
throw
new
Error
(
`Unexpected request: ${method}`
)
;
}
,
}
,
:
{
dispose
(
)
{
}
}
,
:
{
kill
:
(
)
=>
true
}
,
}
as
never
;
await
[
'_refreshCodexModels'
]
(
)
;
.
deepStrictEqual
(
[
'_codexModels'
]
.
map
(
=>
(
{
:
.
,
:
.
}
)
)
,
[
{
:
'codex'
,
:
{
:
'chatgpt'
}
,
}
]
)
;
}
)
;
test
(
'does not relabel a custom provider when ChatGPT authentication is available'
,
async
(
)
=>
{
const
=
createAgent
(
,
async
(
)
=>
[
]
)
;
[
'_connection'
]
=
{
:
'ready'
,
:
{
request
:
async
(
:
string
)
=>
{
if
(
===
'account/read'
)
{
return
{
:
{
:
'chatgpt'
,
:
'person@example.com'
,
:
'plus'
}
,
:
false
}
;
}
if
(
===
'config/read'
)
{
return
{
:
{
:
'custom-provider'
}
}
;
}
if
(
===
'model/list'
)
{
return
;
}
throw
new
Error
(
`Unexpected request: ${method}`
)
;
}
,
}
,
:
{
dispose
(
)
{
}
}
,
:
{
kill
:
(
)
=>
true
}
,
}
as
never
;
await
[
'_refreshCodexModels'
]
(
)
;
.
deepStrictEqual
(
[
'_codexModels'
]
.
map
(
=>
(
{
:
.
,
:
.
}
)
)
,
[
{
:
'codex'
,
:
{
:
'custom-provider'
}
,
}
]
)
;
}
)
;
test
(
'signs out through app-server and refreshes account state'
,
async
(
)
=>
{
const
=
createAgent
(
,
async
(
)
=>
[
]
)
;
const
:
string
[
]
=
[
]
;
[
'_connection'
]
=
{
:
'ready'
,
:
{
request
:
async
(
:
string
)
=>
{
.
push
(
)
;
if
(
===
'account/logout'
)
{
return
{
}
;
}
if
(
===
'account/read'
)
{
return
{
:
null
,
:
true
}
;
}
throw
new
Error
(
`Unexpected request: ${method}`
)
;
}
,
}
,
:
{
dispose
(
)
{
}
}
,
:
{
kill
:
(
)
=>
true
}
,
}
as
never
;
[
'_queueModelRefresh'
]
=
async
(
)
=>
{
}
;
await
[
'_signOutOfChatGPT'
]
(
)
;
.
deepStrictEqual
(
{
// Scoped to the sign-out gesture: with the SDK local, the startup
// `config.toml` read lands on this same connection.
:
.
filter
(
=>
.
startsWith
(
'account/'
)
)
,
:
[
'_openAIAccountState'
]
.
,
}
,
{
:
[
'account/logout'
,
'account/read'
]
,
:
'signedOut'
,
}
)
;
}
)
;
test
(
'clears Copilot proxy credentials and models when authentication is removed'
,
async
(
)
=>
{
const
=
createAgent
(
,
async
(
)
=>
[
]
)
;
const
:
string
[
]
=
[
]
;
[
'_githubToken'
]
=
'stale-token'
;
[
'_copilotModels'
]
=
[
{
:
'copilot'
,
:
toCodexModelSelectionId
(
'vscode-proxy'
,
'gpt-5.3-codex'
)
,
:
'GPT-5.3-Codex'
,
:
false
,
}
]
;
[
'_models'
]
.
set
(
[
'_copilotModels'
]
,
undefined
)
;
[
'_connection'
]
=
{
:
'ready'
,
:
{
request
:
async
(
:
string
)
=>
{
if
(
===
'account/read'
)
{
return
{
:
null
,
:
true
}
;
}
throw
new
Error
(
`Unexpected request: ${method}`
)
;
}
,
}
,
:
{
setToken
:
(
:
string
)
=>
.
push
(
)
,
dispose
(
)
{
}
,
}
,
:
{
kill
:
(
)
=>
true
}
,
}
as
never
;
await
.
authenticate
(
.
getProtectedResources
(
)
[
0
]
.
,
''
)
;
await
.
refreshModels
(
)
;
.
deepStrictEqual
(
{
:
[
'_githubToken'
]
,
,
:
.
.
get
(
)
,
}
,
{
:
undefined
,
:
[
''
]
,
:
[
]
,
}
)
;
}
)
;
test
(
'advertises multiple working directories only while enabled'
,
(
)
=>
{
const
=
createAgent
(
,
async
(
)
=>
[
]
)
;
const
=
.
getDescriptor
(
)
.
?.
;
[
'_configurationService'
]
.
updateRootConfig
(
{
[
]
:
true
}
)
;
const
=
.
getDescriptor
(
)
.
?.
;
[
'_configurationService'
]
.
updateRootConfig
(
{
[
]
:
false
}
)
;
const
=
.
getDescriptor
(
)
.
?.
;
.
deepStrictEqual
(
{
,
,
}
,
{
:
undefined
,
:
{
:
true
}
,
:
undefined
,
}
)
;
}
)
;
}
)
;
suite
(
'CodexAgent — agent SDK setup channel'
,
(
)
=>
{
const
=
ensureNoDisposablesAreLeakedInTestSuite
(
)
;
/** What the workbench would read off root state right now. */
function
readSetup
(
:
)
{
return
readAgentSdkSetupInfos
(
.
.
)
.
find
(
=>
.
===
'codex'
)
;
}
/** Addresses a download request at an agent the way `IAgentSdkSetupService` does. */
function
dispatchDownload
(
:
,
=
'codex'
,
=
'req-1'
)
:
void
{
.
.
updateRootConfig
(
{
[
AGENT_SDK_SETUP_DOWNLOAD_REQUEST_KEY
]
:
{
,
}
}
)
;
}
/** Addresses a reload request the same way, as the banner's link does. */
function
dispatchReload
(
:
,
=
'codex'
,
=
'req-1'
)
:
void
{
.
.
updateRootConfig
(
{
[
AGENT_SDK_SETUP_RELOAD_REQUEST_KEY
]
:
{
,
}
}
)
;
}
/** Waits for the ctor's queued publish (and any refresh it chains) to settle. */
async
function
settle
(
)
:
Promise
<
void
>
{
for
(
let
=
0
;
<
20
;
++
)
{
await
new
Promise<void>
(
=>
setTimeout
(
,
0
)
)
;
}
}
/**
* A build that knows where to fetch the SDK from but has not yet — the state
* the banner's offer exists for. Both flags are set explicitly because
* `isAvailable` false would fall through to `resolveCodexDevSdkRoot()`.
*/
function
createNotDownloaded
(
)
:
{
const
=
new
RecordingAgentSdkDownloader
(
)
;
.
=
false
;
return
;
}
test
(
'an SDK already on disk publishes `ready`, plus the docs URL and sign-in affordance the banner offers'
,
async
(
)
=>
{
const
=
createAgentContext
(
,
async
(
)
=>
[
]
)
;
await
settle
(
)
;
.
deepStrictEqual
(
readSetup
(
)
,
{
:
'codex'
,
:
'ready'
,
:
'https://learn.chatgpt.com/codex/auth'
,
// Unlike Claude, ChatGPT sign-in is a control request the app server
// answers, so the banner can start it without the user leaving the window.
:
'ChatGPT'
,
}
)
;
}
)
;
test
(
'a cold cache publishes `notDownloaded`, which is what turns the banner into an offer'
,
async
(
)
=>
{
const
=
createAgentContext
(
,
async
(
)
=>
[
]
,
{
}
,
createNotDownloaded
(
)
)
;
await
settle
(
)
;
.
strictEqual
(
readSetup
(
)
?.
,
'notDownloaded'
)
;
}
)
;
test
(
'an explicit download fetches the SDK, holds progress interest for the fetch, and ends at `ready`'
,
async
(
)
=>
{
const
=
createNotDownloaded
(
)
;
let
releaseDownload
=
(
)
=>
{
}
;
const
=
new
Promise<void>
(
=>
{
// Releasing the gate is the moment the SDK lands on disk.
releaseDownload
=
(
)
=>
{
.
=
true
;
resolve
(
)
;
}
;
}
)
;
.
loadSdkRootResult
=
async
(
)
=>
{
await
;
return
'/tmp/codex-sdk'
;
}
;
const
=
createAgentContext
(
,
async
(
)
=>
[
]
,
{
}
,
)
;
// The refresh the download chains must not spawn a real app server.
.
[
'_ensureConnection'
]
=
async
(
)
=>
{
throw
new
Error
(
'offline'
)
;
}
;
await
settle
(
)
;
dispatchDownload
(
)
;
await
settle
(
)
;
const
=
{
:
readSetup
(
)
?.
,
:
[
...
.
]
,
:
.
,
}
;
releaseDownload
(
)
;
await
settle
(
)
;
.
deepStrictEqual
(
{
,
:
readSetup
(
)
?.
,
:
.
}
,
{
:
{
:
'downloading'
,
:
[
'codex'
]
,
:
1
}
,
:
'ready'
,
:
0
,
}
)
;
}
)
;
test
(
'a download that lands publishes ready without starting a persistent catalog connection'
,
async
(
)
=>
{
const
=
createNotDownloaded
(
)
;
.
loadSdkRootResult
=
async
(
)
=>
{
.
=
true
;
return
'/tmp/codex-sdk'
;
}
;
const
=
createAgentContext
(
,
async
(
)
=>
[
]
,
{
}
,
)
;
let
=
0
;
.
[
'_ensureConnection'
]
=
async
(
)
=>
{
++
;
throw
new
Error
(
'persistent connection should remain stopped'
)
;
}
;
await
settle
(
)
;
dispatchDownload
(
)
;
await
settle
(
)
;
.
deepStrictEqual
(
{
:
readSetup
(
)
?.
,
:
.
.
.
get
(
)
.
,
}
,
{
:
'ready'
,
:
0
,
:
0
,
}
)
;
}
)
;
test
(
'the request key is cleared as it is consumed, so an identical later press still lands'
,
async
(
)
=>
{
const
=
createNotDownloaded
(
)
;
let
=
0
;
.
loadSdkRootResult
=
async
(
)
=>
{
++
;
return
'/tmp/codex-sdk'
;
}
;
const
=
createAgentContext
(
,
async
(
)
=>
[
]
,
{
}
,
)
;
.
[
'_ensureConnection'
]
=
async
(
)
=>
{
throw
new
Error
(
'offline'
)
;
}
;
await
settle
(
)
;
dispatchDownload
(
,
'codex'
,
'press-1'
)
;
await
settle
(
)
;
const
=
.
.
getRootConfigValues
(
)
[
AGENT_SDK_SETUP_DOWNLOAD_REQUEST_KEY
]
;
dispatchDownload
(
,
'codex'
,
'press-2'
)
;
await
settle
(
)
;
.
deepStrictEqual
(
{
,
}
,
{
:
undefined
,
:
2
}
)
;
}
)
;
test
(
'a request addressed to another agent is ignored'
,
async
(
)
=>
{
const
=
createNotDownloaded
(
)
;
const
=
createAgentContext
(
,
async
(
)
=>
[
]
,
{
}
,
)
;
await
settle
(
)
;
dispatchDownload
(
,
'claude'
)
;
await
settle
(
)
;
.
deepStrictEqual
(
{
:
.
,
// Left in place for the agent it names, rather than consumed by this one.
:
.
.
getRootConfigValues
(
)
[
AGENT_SDK_SETUP_DOWNLOAD_REQUEST_KEY
]
,
}
,
{
:
[
]
,
:
{
:
'claude'
,
:
'req-1'
}
,
}
)
;
}
)
;
test
(
'a failed download releases the progress interest and stops claiming to be downloading'
,
async
(
)
=>
{
const
=
createNotDownloaded
(
)
;
.
loadSdkRootResult
=
async
(
)
=>
{
throw
new
Error
(
'CDN unreachable'
)
;
}
;
const
=
createAgentContext
(
,
async
(
)
=>
[
]
,
{
}
,
)
;
await
settle
(
)
;
dispatchDownload
(
)
;
await
settle
(
)
;
.
deepStrictEqual
(
{
:
readSetup
(
)
?.
,
:
.
,
}
,
{
:
'notDownloaded'
,
:
0
,
}
)
;
}
)
;
test
(
'a reload is claimed here too, since the request handling is the shared channel and not per-agent code'
,
async
(
)
=>
{
const
=
createAgentContext
(
,
async
(
)
=>
[
]
)
;
.
[
'_ensureConnection'
]
=
async
(
)
=>
{
throw
new
Error
(
'offline'
)
;
}
;
await
settle
(
)
;
dispatchReload
(
)
;
await
settle
(
)
;
.
deepStrictEqual
(
{
:
.
.
getRootConfigValues
(
)
[
AGENT_SDK_SETUP_RELOAD_REQUEST_KEY
]
,
// Reload only re-reads what is already there; nothing is ever fetched.