codexAgent.ts ×24

Frontier kind: Code frontier

unlabeled · c_2cedf3492141

3 tests · 36402 LOC · 192 files · introduces 0 tests · 89 LOC · 2 files

Introduces — evidence that enters the hierarchy at this concept

Code
25 ranges89 lines · 2 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
3228 ranges36402 lines · 192 files · Browse complete extent
All tests (intent)
3 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

2 files ranked by introduced lines: 89 introduced LOC across 25 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/agentHost/node/codex/codexAgent.ts 86 introduced LOC · 24 ranges

Open complete file

771
772 constructor(
773 > @ILogService private readonly _logService: ILogService, codexAgent.ts
774 > @ICopilotApiService private readonly _copilotApiService: ICopilotApiService,
775 > @ICodexProxyService private readonly _codexProxyService: ICodexProxyService,
776 > @IAgentConfigurationService private readonly _configurationService: IAgentConfigurationService,
777 > @IAgentHostGitHubEndpointService private readonly _gitHubEndpointService: IAgentHostGitHubEndpointService,
778 > @IAgentSdkDownloader private readonly _agentSdkDownloader: IAgentSdkDownloader,
779 > @IProductService private readonly _productService: IProductService,
780 > @IAgentPluginManager private readonly _pluginManager: IAgentPluginManager,
781 > @IFileService private readonly _fileService: IFileService,
782 > @INativeEnvironmentService private readonly _environmentService: INativeEnvironmentService,
783 > @IInstantiationService private readonly _instantiationService: IInstantiationService,
784 > ) {
785 > super();
786 > this._metadataStore = this._instantiationService.createInstance(CodexSessionMetadataStore);
787 > this._usageSource = this._resolveUsageSource();
788 > this._register(this._configurationService.onDidRootConfigChange(() => {
789 const next = this._resolveUsageSource();
790 if (next !== this._usageSource) {
794 }
795 this._queueProviderConfigurationWrite();
796 > })); codexAgent.ts
797 > void this._refreshProviderConfiguration();
798 > if (this._usageSource === 'openai') {
799 this._usageSourceValidation = this._validateOpenAIUsageSource();
800 }
801 > } codexAgent.ts
802
803 private async _validateOpenAIUsageSource(): Promise<void> {
833
834 private _resolveUsageSource(): CodexUsageSource {
835 > return this._configurationService.getRootValue(agentHostCustomizationConfigSchema, AgentHostConfigKey.CodexUsageSource) ?? 'copilot'; codexAgent.ts
836 > }
837
838 private _requestUsageSourceChange(source: CodexUsageSource): void {
902
903 getProtectedResources(): ProtectedResourceMetadata[] {
904 > return codexProtectedResourcesForUsageSource( codexAgent.ts
905 > this._usageSource,
906 > this._gitHubEndpointService.getCopilotResource(),
907 > this._gitHubEndpointService.getRepoResource(),
908 > );
909 > }
910
911 async authenticate(resource: string, token: string): Promise<boolean> {
1043
1044 private _ensureAuthenticated(): string | undefined {
1045 > if (this._usageSource === 'openai') { codexAgent.ts
1046 return undefined;
1047 }
1048 > const token = this._githubToken; codexAgent.ts
1049 > if (!token) {
1050 > throw new ProtocolError(
1051 > AHP_AUTH_REQUIRED,
1052 > 'Authentication is required to use Codex',
1053 > this.getProtectedResources(),
1054 > );
1055 > }
1056 return token;
1057 > } codexAgent.ts
1058
1059 private _defaultModel(): ModelSelection | undefined {
1295 */
1296 private async _ensureConnection(skipUsageSourceValidation = false): Promise<IConnectionReady> {
1297 > if (this._connection.kind === 'ready') { codexAgent.ts
1298 return Promise.resolve(this._connection);
1299 }
1300 > if (this._connection.kind === 'starting') { codexAgent.ts
1301 return this._connection.promise;
1302 }
1303 > if (!skipUsageSourceValidation && this._usageSource === 'openai') { codexAgent.ts
1304 let validation = this._usageSourceValidation;
1305 await validation;
1309 }
1310 }
1311 > const token = this._ensureAuthenticated(); codexAgent.ts
1312 > const usageSource = this._usageSource;
1313 > const generation = this._connectionGeneration;
1314 > const startPromise = this._startConnection(usageSource, token);
1315 > const promise = startPromise.then(ready => {
1316 if (generation !== this._connectionGeneration || usageSource !== this._usageSource) {
1317 ready.client.dispose();
1322 this._connection = { kind: 'ready', ...ready };
1323 return ready;
1324 > }).catch(err => { codexAgent.ts
1325 if (generation === this._connectionGeneration) {
1326 this._connection = { kind: 'idle' };
1327 }
1328 throw err;
1329 > }); codexAgent.ts
1330 > this._connection = { kind: 'starting', promise };
1331 > return promise;
1332 > }
1333
1334 /**
1971
1972 private async _readProviderConfiguration(): Promise<Record<string, unknown>> {
1973 > const connection = await this._ensureConnection(); codexAgent.ts
1974 const response = await connection.client.request<'config/read', ConfigReadResponse>('config/read', { includeLayers: true });
1975 > const userLayer = response.layers?.find(layer => layer.name.type === 'user' && layer.name.profile === null) ?? response.layers?.find(layer => layer.name.type === 'user'); codexAgent.ts
1976 > const config = userLayer?.config && typeof userLayer.config === 'object' && !Array.isArray(userLayer.config) ? userLayer.config as Record<string, unknown> : {};
1977 > return {
1978 > 'codex.personality': this._readConfigurationValue(config, 'personality') ?? 'default',
1979 > 'codex.autoReviewPolicy': this._readConfigurationValue(config, 'auto_review.policy') ?? '',
1980 > };
1981 > }
1982
1983 private async _writeProviderConfiguration(key: string, value: unknown): Promise<void> {
1995
1996 private _refreshProviderConfiguration(): Promise<void> {
1997 > return this._providerConfigurationRefresh ??= (async () => { codexAgent.ts
1998 > try {
1999 > this._providerConfigurationValues = await this._readProviderConfiguration();
2000 this._providerConfigurationReady = true;
2001 this._configurationService.updateRootConfig(this._providerConfigurationValues);
2002 > } catch (error) { codexAgent.ts
2003 > this._logService.warn(`[Codex] Failed to read config.toml: ${error instanceof Error ? error.message : String(error)}`);
2004 > } finally {
2005 > this._providerConfigurationRefresh = undefined;
2006 > }
2007 > })();
2008 > }
2009
2010 private _queueProviderConfigurationWrite(): void {
2594
2595 private _disposeConnection(): void {
2596 > const connection = this._connection; codexAgent.ts
2597 > this._connectionGeneration++;
2598 > this._connection = { kind: 'idle' };
2599 > if (connection.kind !== 'ready') {
2600 > return;
2601 > }
2602 try { connection.client.dispose(); } catch { /* ignore */ }
2603 > try { connection.proxyHandle?.dispose(); } catch { /* ignore */ } codexAgent.ts
2604 try { connection.child.kill('SIGKILL'); } catch { /* already dead */ }
2605 > } codexAgent.ts
2606
2607 // #endregion
4291
4292 override dispose(): void {
4293 > this._disposeConnection(); codexAgent.ts
4294 > for (const s of this._sessions.values()) {
4295 s.pendingCommandApprovals.denyAll('decline');
4296 s.pendingClientToolCalls.rejectAll(new CancellationError());
4298 s.mcpController?.dispose();
4299 }
4300 > for (const subagent of this._subagentsByThreadId.values()) { codexAgent.ts
4301 subagent.session.pendingCommandApprovals.denyAll('decline');
4302 }
4303 > this._subagentsByThreadId.clear(); codexAgent.ts
4304 > this._sessions.clear();
4305 > this._sessionIdByThreadId.clear();
4306 > this._mcpInventory.clear();
4307 > super.dispose();
4308 > }
4309 }
4310
src/vs/platform/agentHost/node/codex/codexSessionMetadataStore.ts 3 introduced LOC · 1 range

Open complete file

46
47 constructor(
48 > @ISessionDataService private readonly _sessionDataService: ISessionDataService, codexSessionMetadataStore.ts
49 > @ILogService private readonly _logService: ILogService,
50 > ) { }
51
52 /**