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 / providerIntegration / codexCustomizations.integrationTest.ts 397 строк · изменён 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
import assert from 'assert' ;
import { mkdir, mkdtemp, readFile, readdir, rm, writeFile } from 'fs/promises' ;
import { createRequire } from 'module' ;
import { tmpdir } from 'os' ;
import { join } from '../../../../../base/common/path.js' ;
import { URI } from '../../../../../base/common/uri.js' ;
import { generateUuid } from '../../../../../base/common/uuid.js'
ActionType
AgentHostCodexEnabledConfigKey
buildDefaultChatUri customizationId CustomizationType MessageKind ProtocolURI
fetchSessionWithChat getActionEnvelope isActionNotification startRealServer stopServer TestProtocolClient
nodeRequire meta url
path
body
body
input body input input
input
input item item item item role role
client TestProtocolClient sessionUri pluginUri PluginCustomization
deadline Date
lastPlugin PluginCustomization
Date deadline
session client sessionUri
plugin session customizations customization customization PluginCustomization
customization type CustomizationType Plugin
customization uri pluginUri
lastPlugin plugin
plugin
plugin children length
plugin children child child McpServerCustomization child type CustomizationType McpServer
plugin
resolve resolve
client TestProtocolClient sessionUri agentUri DirectoryCustomization
deadline Date
Date deadline
session client sessionUri
directory session customizations customization customization DirectoryCustomization
customization type CustomizationType Directory
customization contents CustomizationType Agent
customization children child child type CustomizationType Agent child uri agentUri
directory
directory
resolve resolve
server IServerHandle
client TestProtocolClient
userHomeDir
createdSessions
tempDirs
userHomeDir
codexHomeDir userHomeDir
codexHomeDir recursive
server
mockLlm
codexSdkRoot
codexHomeDir
homeDir userHomeDir
userDataDir userHomeDir
server
userHomeDir recursive force maxRetries retryDelay
client server port
client
session createdSessions
session
createdSessions length
client
dir tempDirs
dir recursive force maxRetries retryDelay
tempDirs length
workspaceDir
pluginDir
tempDirs workspaceDir pluginDir
agentFile pluginDir
skillFile pluginDir
instructionFile pluginDir
mcpScript pluginDir
mcpConfigFile pluginDir
pluginUri pluginDir
pluginDir recursive
pluginDir recursive
pluginDir recursive
pluginDir recursive
mcpServerModule nodeRequire
mcpStdioModule nodeRequire
mcpTypesModule nodeRequire
pluginDir name
agentFile
instructionFile
skillFile
mcpScript
mcpConfigFile
mcpServers
customization_test
command process execPath
args mcpScript
env
clientId
channel protocolVersions clientId
channel resource token
pluginCustomization ClientPluginCustomization
type CustomizationType Plugin
id pluginUri
uri pluginUri ProtocolURI
name
nonce
sessionUri scheme path
channel sessionUri
provider
workingDirectories workspaceDir
config isolation
activeClient
clientId
tools
customizations pluginCustomization
createdSessions sessionUri
client channel sessionUri
client channel sessionUri
client
parsedPlugin client sessionUri pluginUri
assert
parsedPlugin children child child type
CustomizationType Agent CustomizationType Rule CustomizationType Skill CustomizationType McpServer
turnId
client
channel sessionUri
clientSeq
action
type ActionType ChatTurnStarted
turnId
startedAt
message
text
origin kind MessageKind User
agent uri agentFile
client notification
notification
notification channel sessionUri
notification action turnId turnId turnId
rolloutRoot userHomeDir
rolloutFiles rolloutRoot recursive file file
rolloutContents rolloutFiles file rolloutRoot file
assert rolloutContents content content
requests server mockLlm getRequests ICapturedRequest
responsesRequest requests request request path
assert responsesRequest
requestText responsesRequest body
developerText responsesRequest body
assert developerText
assert developerText
assert requestText
assert requestText
workspaceDir
tempDirs workspaceDir
agentsDir workspaceDir
agentFile agentsDir
agentUri agentFile
agentsDir recursive
agentFile
clientId
channel protocolVersions clientId
channel resource token
sessionUri scheme path
channel sessionUri
provider
workingDirectories workspaceDir
config isolation
activeClient clientId tools customizations
createdSessions sessionUri
client channel sessionUri
client channel sessionUri
client
directory client sessionUri agentUri
assert directory children child type child type name child name uri child uri
type CustomizationType Agent
name
uri agentUri
turnId
client
channel sessionUri
clientSeq
action
type ActionType ChatTurnStarted
turnId
startedAt
message
text
origin kind MessageKind User
agent uri agentUri
client notification
notification
notification channel sessionUri
notification action turnId turnId turnId
requests server mockLlm getRequests ICapturedRequest
responsesRequest requests request request path
assert responsesRequest
assert responsesRequest body
runtimeHomeDir
workspaceDir
runtimeCodexHomeDir runtimeHomeDir
runtimeCodexHomeDir recursive
runtimeServer
mockLlm
codexSdkRoot
codexHomeDir runtimeCodexHomeDir
codexAgentEnabled
homeDir runtimeHomeDir
userDataDir runtimeHomeDir
runtimeClient runtimeServer port
runtimeClient
channel protocolVersions clientId
runtimeClient channel
runtimeClient
runtimeClient
channel
clientSeq
action type ActionType RootConfigChanged config AgentHostCodexEnabledConfigKey
runtimeClient notification
notification ActionType RootConfigChanged
notification action config Readonly Record config AgentHostCodexEnabledConfigKey
runtimeClient notification
notification ActionType RootAgentsChanged
notification action RootAgentsChangedAction agents agent agent provider
channel resource resource token
sessionUri scheme path
channel sessionUri
provider
workingDirectories workspaceDir
config isolation
runtimeClient
runtimeServer
runtimeHomeDir recursive force maxRetries retryDelay
workspaceDir recursive force maxRetries retryDelay
;
import
{
,
type
RootAgentsChangedAction
}
from
'../../../common/state/sessionActions.js'
;
import
{
}
from
'../../../common/agentHostSchema.js'
;
import
{
GITHUB_COPILOT_PROTECTED_RESOURCE
}
from
'../../../common/agent.js'
;
import
{
PROTOCOL_VERSION
}
from
'../../../common/state/protocol/version/registry.js'
;
import
{
type
SubscribeResult
}
from
'../../../common/state/protocol/commands.js'
;
import
{
,
,
,
,
ROOT_STATE_URI
,
type
ClientPluginCustomization
,
type
DirectoryCustomization
,
type
McpServerCustomization
,
type
PluginCustomization
,
type
URI
as
}
from
'../../../common/state/sessionState.js'
;
import
{
,
,
,
type
IServerHandle
,
,
,
}
from
'../serverIntegrationTestHelpers.js'
;
import
{
CODEX_SDK_ROOT
}
from
'../e2e/providers/codexTestConfiguration.js'
;
const
AGENT_MARKER
=
'CODEX_CUSTOM_AGENT_INSTRUCTION_MARKER'
;
const
WORKSPACE_AGENT_MARKER
=
'CODEX_WORKSPACE_AGENT_INSTRUCTION_MARKER'
;
const
RULE_MARKER
=
'CODEX_PLUGIN_RULE_MARKER'
;
const
SKILL_MARKER
=
'CODEX_PLUGIN_SKILL_DESCRIPTION_MARKER'
;
const
MCP_MARKER
=
'CODEX_PLUGIN_MCP_TOOL_MARKER'
;
const
=
createRequire
(
import
.
.
)
;
interface
ICapturedRequest
{
readonly
:
string
;
readonly
:
unknown
;
}
function
developerInputText
(
:
unknown
)
:
string
{
const
=
(
as
{
readonly
?
:
unknown
}
|
undefined
)
?.
;
return
Array
.
isArray
(
)
?
JSON
.
stringify
(
.
filter
(
=>
&&
typeof
===
'object'
&&
(
as
{
readonly
?
:
unknown
}
)
.
===
'developer'
)
)
:
''
;
}
async
function
waitForParsedPlugin
(
:
,
:
string
,
:
string
)
:
Promise
<
>
{
const
=
.
now
(
)
+
60_000
;
let
:
|
undefined
;
while
(
.
now
(
)
<
)
{
const
=
await
fetchSessionWithChat
(
,
)
;
const
=
.
?.
find
(
(
)
:
is
=>
.
===
.
&&
.
===
)
;
=
;
if
(
&&
(
.
?.
??
0
)
>=
4
&&
.
?.
some
(
(
)
:
is
=>
.
===
.
)
===
true
)
{
return
;
}
await
new
Promise < void >
(
=>
setTimeout
(
,
100
)
)
;
}
throw
new
Error
(
` Timed out waiting for parsed plugin ${ pluginUri} ; last state: ${ JSON . stringify ( lastPlugin) } `
)
;
}
async
function
waitForWorkspaceAgent
(
:
,
:
string
,
:
string
)
:
Promise
<
>
{
const
=
.
now
(
)
+
60_000
;
while
(
.
now
(
)
<
)
{
const
=
await
fetchSessionWithChat
(
,
)
;
const
=
.
?.
find
(
(
)
:
is
=>
.
===
.
&&
.
===
.
&&
.
?.
some
(
=>
.
===
.
&&
.
===
)
===
true
)
;
if
(
)
{
return
;
}
await
new
Promise < void >
(
=>
setTimeout
(
,
100
)
)
;
}
throw
new
Error
(
` Timed out waiting for workspace agent ${ agentUri} `
)
;
}
suite
(
'Agent Host Provider Integration — Codex Customizations'
,
function
(
)
{
let
:
;
let
:
;
let
:
string
;
const
:
string
[
]
=
[
]
;
const
:
string
[
]
=
[
]
;
suiteSetup
(
async
function
(
)
{
this
.
timeout
(
120_000
)
;
if
(
!
CODEX_SDK_ROOT
)
{
this
.
skip
(
)
;
}
=
await
mkdtemp
(
join
(
tmpdir
(
)
,
'codex-customizations-home-'
)
)
;
const
=
join
(
,
'.codex'
)
;
await
mkdir
(
,
{
:
true
}
)
;
=
await
startRealServer
(
{
:
true
,
:
CODEX_SDK_ROOT
,
,
:
,
:
join
(
,
'user-data'
)
,
}
)
;
}
)
;
suiteTeardown
(
async
function
(
)
{
this
.
timeout
(
60_000
)
;
await
stopServer
(
)
;
await
rm
(
,
{
:
true
,
:
true
,
:
5
,
:
200
}
)
;
}
)
;
setup
(
async
function
(
)
{
this
.
timeout
(
120_000
)
;
=
new
TestProtocolClient
(
.
)
;
await
.
connect
(
)
;
}
)
;
teardown
(
async
function
(
)
{
for
(
const
of
)
{
try
{
await
client
.
call
(
'disposeSession'
,
{
}
,
5000
)
;
}
catch
{
}
}
.
=
0
;
.
close
(
)
;
for
(
const
of
)
{
try
{
await
rm
(
,
{
:
true
,
:
true
,
:
5
,
:
200
}
)
;
}
catch
{
}
}
.
=
0
;
}
)
;
test
(
'client plugin agents, instructions, skills, and MCP reach Codex'
,
async
function
(
)
{
this
.
timeout
(
180_000
)
;
const
=
await
mkdtemp
(
join
(
tmpdir
(
)
,
'codex-customizations-workspace-'
)
)
;
const
=
await
mkdtemp
(
join
(
tmpdir
(
)
,
'codex-customizations-plugin-'
)
)
;
.
push
(
,
)
;
const
=
join
(
,
'agents'
,
'reviewer.agent.md'
)
;
const
=
join
(
,
'skills'
,
'customization-skill'
,
'SKILL.md'
)
;
const
=
join
(
,
'rules'
,
'customization.instructions.md'
)
;
const
=
join
(
,
'customization-mcp.cjs'
)
;
const
=
join
(
,
'.mcp.json'
)
;
const
=
URI
.
file
(
)
.
toString
(
)
;
await
Promise
.
all
(
[
mkdir
(
join
(
,
'.plugin'
)
,
{
:
true
}
)
,
mkdir
(
join
(
,
'agents'
)
,
{
:
true
}
)
,
mkdir
(
join
(
,
'skills'
,
'customization-skill'
)
,
{
:
true
}
)
,
mkdir
(
join
(
,
'rules'
)
,
{
:
true
}
)
,
]
)
;
const
=
.
resolve
(
'@modelcontextprotocol/sdk/server/index.js'
)
;
const
=
.
resolve
(
'@modelcontextprotocol/sdk/server/stdio.js'
)
;
const
=
.
resolve
(
'@modelcontextprotocol/sdk/types.js'
)
;
await
Promise
.
all
(
[
writeFile
(
join
(
,
'.plugin'
,
'plugin.json'
)
,
JSON
.
stringify
(
{
:
'Codex Customizations Test Plugin'
}
)
)
,
writeFile
(
,
[
'---'
,
'name: Codex Custom Reviewer'
,
'description: Reviews changes using the integration-test policy.'
,
'---'
,
` Always follow ${ AGENT_MARKER } . `
,
]
.
join
(
'\n'
)
)
,
writeFile
(
,
[
'---'
,
'name: Codex Integration Rule'
,
'applyTo:'
,
' - "**/*"'
,
'---'
,
` Always follow ${ RULE_MARKER } . `
,
]
.
join
(
'\n'
)
)
,
writeFile
(
,
[
'---'
,
'name: customization-skill'
,
` description: ${ SKILL_MARKER } `
,
'---'
,
'Use this skill when validating Codex customization propagation.'
,
]
.
join
(
'\n'
)
)
,
writeFile
(
,
[
` const { Server } = require( ${ JSON . stringify ( mcpServerModule) } ); `
,
` const { StdioServerTransport } = require( ${ JSON . stringify ( mcpStdioModule) } ); `
,
` const { CallToolRequestSchema, ListToolsRequestSchema } = require( ${ JSON . stringify ( mcpTypesModule) } ); `
,
` const server = new Server({ name: "codex-customization-test", version: "1.0.0" }, { capabilities: { tools: {} } }); `
,
` server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [{ name: "customization_probe", description: ${ JSON . stringify ( MCP_MARKER ) } , inputSchema: { type: "object", properties: {} } }] })); `
,
` server.setRequestHandler(CallToolRequestSchema, async () => ({ content: [{ type: "text", text: "customization MCP response" }] })); `
,
'void server.connect(new StdioServerTransport());'
,
]
.
join
(
'\n'
)
)
,
writeFile
(
,
JSON
.
stringify
(
{
:
{
:
{
:
.
,
:
[
]
,
:
{
ELECTRON_RUN_AS_NODE
:
'1'
}
,
}
,
}
,
}
)
)
,
]
)
;
const
=
'codex-customizations-client'
;
await
client
.
call
(
'initialize'
,
{
:
ROOT_STATE_URI
,
:
[
PROTOCOL_VERSION
]
,
}
,
30_000
)
;
await
client
.
call
(
'authenticate'
,
{
:
ROOT_STATE_URI
,
:
'https://api.github.com'
,
:
'not-a-real-token'
}
,
30_000
)
;
const
:
=
{
:
.
,
:
customizationId
(
)
,
:
as
,
:
'Codex Customizations Test Plugin'
,
:
'1'
,
}
;
const
=
URI
.
from
(
{
:
'codex'
,
:
` / ${ generateUuid ( ) } `
}
)
.
toString
(
)
;
await
client
.
call
(
'createSession'
,
{
:
,
:
'codex'
,
:
[
URI
.
file
(
)
.
toString
(
)
]
,
:
{
:
'folder'
}
,
:
{
,
:
[
]
,
:
[
]
,
}
,
}
,
30_000
)
;
.
push
(
)
;
await
.
call < SubscribeResult>
(
'subscribe'
,
{
:
}
)
;
await
.
call < SubscribeResult>
(
'subscribe'
,
{
:
buildDefaultChatUri
(
)
}
)
;
.
clearReceived
(
)
;
const
=
await
waitForParsedPlugin
(
,
,
)
;
.
deepStrictEqual
(
new
Set
(
.
?.
map
(
=>
.
)
)
,
new
Set
(
[
.
,
.
,
.
,
.
]
)
,
)
;
const
=
'turn-codex-customizations'
;
.
dispatch
(
{
:
buildDefaultChatUri
(
)
,
:
1
,
:
{
:
.
,
,
:
'2026-08-04T00:00:00.000Z'
,
:
{
:
'Reply with exactly CODEX_CUSTOMIZATIONS_OK.'
,
:
{
:
.
}
,
:
{
:
URI
.
file
(
)
.
toString
(
)
}
,
}
,
}
,
}
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/turnComplete'
)
&&
getActionEnvelope
(
)
.
===
buildDefaultChatUri
(
)
&&
(
getActionEnvelope
(
)
.
as
{
?
:
string
}
)
.
===
,
120_000
,
)
;
const
=
join
(
,
'.codex'
,
'sessions'
)
;
const
=
(
await
readdir
(
,
{
:
true
}
)
)
.
filter
(
=>
.
endsWith
(
'.jsonl'
)
)
;
const
=
await
Promise
.
all
(
.
map
(
=>
readFile
(
join
(
,
)
,
'utf8'
)
)
)
;
.
ok
(
.
some
(
=>
.
includes
(
'CODEX_CUSTOMIZATIONS_OK'
)
)
,
'Codex test rollouts must be written under the isolated test home'
)
;
const
=
(
.
?.
?.
(
)
??
[
]
)
as
readonly
[
]
;
const
=
[
...
]
.
reverse
(
)
.
find
(
=>
.
.
includes
(
'/responses'
)
)
;
.
ok
(
,
` expected a Codex /responses request; got paths: ${ requests. map ( request => request. path) . join ( ', ' ) } `
)
;
const
=
JSON
.
stringify
(
.
)
;
const
=
developerInputText
(
.
)
;
.
ok
(
.
includes
(
AGENT_MARKER
)
,
'selected custom-agent instructions must reach the Codex developer message'
)
;
.
ok
(
.
includes
(
RULE_MARKER
)
,
'plugin instructions must reach the Codex developer message'
)
;
.
ok
(
.
includes
(
SKILL_MARKER
)
,
'plugin skills must be advertised in the Codex model request'
)
;
.
ok
(
.
includes
(
MCP_MARKER
)
,
'plugin MCP tools must be advertised in the Codex model request'
)
;
}
)
;
test
(
'workspace agent is exposed and selected without client customization sync'
,
async
function
(
)
{
this
.
timeout
(
180_000
)
;
const
=
await
mkdtemp
(
join
(
tmpdir
(
)
,
'codex-workspace-agent-'
)
)
;
.
push
(
)
;
const
=
join
(
,
'.github'
,
'agents'
)
;
const
=
join
(
,
'workspace-reviewer.agent.md'
)
;
const
=
URI
.
file
(
)
.
toString
(
)
;
await
mkdir
(
,
{
:
true
}
)
;
await
writeFile
(
,
[
'---'
,
'name: Workspace Reviewer'
,
'description: Reviews this workspace.'
,
'---'
,
` Always follow ${ WORKSPACE_AGENT_MARKER } . `
,
]
.
join
(
'\n'
)
)
;
const
=
'codex-workspace-agent-client'
;
await
client
.
call
(
'initialize'
,
{
:
ROOT_STATE_URI
,
:
[
PROTOCOL_VERSION
]
,
}
,
30_000
)
;
await
client
.
call
(
'authenticate'
,
{
:
ROOT_STATE_URI
,
:
'https://api.github.com'
,
:
'not-a-real-token'
}
,
30_000
)
;
const
=
URI
.
from
(
{
:
'codex'
,
:
` / ${ generateUuid ( ) } `
}
)
.
toString
(
)
;
await
client
.
call
(
'createSession'
,
{
:
,
:
'codex'
,
:
[
URI
.
file
(
)
.
toString
(
)
]
,
:
{
:
'folder'
}
,
:
{
,
:
[
]
,
:
[
]
}
,
}
,
30_000
)
;
.
push
(
)
;
await
.
call < SubscribeResult>
(
'subscribe'
,
{
:
}
)
;
await
.
call < SubscribeResult>
(
'subscribe'
,
{
:
buildDefaultChatUri
(
)
}
)
;
.
clearReceived
(
)
;
const
=
await
waitForWorkspaceAgent
(
,
,
)
;
.
deepStrictEqual
(
.
?.
map
(
=>
(
{
:
.
,
:
.
,
:
.
}
)
)
,
[
{
:
.
,
:
'Workspace Reviewer'
,
:
,
}
]
)
;
const
=
'turn-codex-workspace-agent'
;
.
dispatch
(
{
:
buildDefaultChatUri
(
)
,
:
1
,
:
{
:
.
,
,
:
'2026-08-13T00:00:00.000Z'
,
:
{
:
'Reply with exactly CODEX_WORKSPACE_AGENT_OK.'
,
:
{
:
.
}
,
:
{
:
}
,
}
,
}
,
}
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
'chat/turnComplete'
)
&&
getActionEnvelope
(
)
.
===
buildDefaultChatUri
(
)
&&
(
getActionEnvelope
(
)
.
as
{
?
:
string
}
)
.
===
,
120_000
,
)
;
const
=
(
.
?.
?.
(
)
??
[
]
)
as
readonly
[
]
;
const
=
[
...
]
.
reverse
(
)
.
find
(
=>
.
.
includes
(
'/responses'
)
)
;
.
ok
(
,
` expected a Codex /responses request; got paths: ${ requests. map ( request => request. path) . join ( ', ' ) } `
)
;
.
ok
(
developerInputText
(
.
)
.
includes
(
WORKSPACE_AGENT_MARKER
)
,
'selected workspace-agent instructions must reach the Codex developer message'
)
;
}
)
;
test
(
'standalone host registers Codex after runtime enablement'
,
async
function
(
)
{
this
.
timeout
(
120_000
)
;
const
=
await
mkdtemp
(
join
(
tmpdir
(
)
,
'codex-runtime-enablement-home-'
)
)
;
const
=
await
mkdtemp
(
join
(
tmpdir
(
)
,
'codex-runtime-enablement-'
)
)
;
const
=
join
(
,
'.codex'
)
;
await
mkdir
(
,
{
:
true
}
)
;
const
=
await
startRealServer
(
{
:
true
,
:
CODEX_SDK_ROOT
,
:
,
:
false
,
:
,
:
join
(
,
'user-data'
)
,
}
)
;
const
=
new
TestProtocolClient
(
.
)
;
try
{
await
.
connect
(
)
;
await
runtimeClient
.
call
(
'initialize'
,
{
:
ROOT_STATE_URI
,
:
[
PROTOCOL_VERSION
]
,
:
'codex-runtime-enablement-client'
}
,
30_000
)
;
await
.
call < SubscribeResult>
(
'subscribe'
,
{
:
ROOT_STATE_URI
}
)
;
.
clearReceived
(
)
;
.
dispatch
(
{
:
ROOT_STATE_URI
,
:
1
,
:
{
:
.
,
:
{
[
]
:
true
}
}
,
}
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
.
)
&&
(
getActionEnvelope
(
)
.
as
{
readonly
?
:
<
<
string
,
boolean
>>
}
)
.
?.
[
]
===
true
,
30_000
,
)
;
await
.
waitForNotification
(
=>
isActionNotification
(
,
.
)
&&
(
getActionEnvelope
(
)
.
as
)
.
.
some
(
=>
.
===
'codex'
)
,
30_000
,
)
;
await
runtimeClient
.
call
(
'authenticate'
,
{
:
ROOT_STATE_URI
,
:
GITHUB_COPILOT_PROTECTED_RESOURCE
.
,
:
'not-a-real-token'
}
,
30_000
)
;
const
=
URI
.
from
(
{
:
'codex'
,
:
` / ${ generateUuid ( ) } `
}
)
.
toString
(
)
;
await
runtimeClient
.
call
(
'createSession'
,
{
:
,
:
'codex'
,
:
[
URI
.
file
(
)
.
toString
(
)
]
,
:
{
:
'folder'
}
,
}
,
30_000
)
;
}
finally
{
.
close
(
)
;
await
stopServer
(
)
;
await
Promise
.
all
(
[
rm
(
,
{
:
true
,
:
true
,
:
5
,
:
200
}
)
,
rm
(
,
{
:
true
,
:
true
,
:
5
,
:
200
}
)
,
]
)
;
}
}
)
;
}
)
;