codexAgent.ts ×13

Frontier kind: Joint frontier

unlabeled · c_7ad272f7693c

1 test · 36625 LOC · 193 files · introduces 1 test · 83 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
13 ranges83 lines · 1 files
Tests
1 test

Contains — complete concept membership

All code (extent)
3275 ranges36625 lines · 193 files · Browse complete extent
All tests (intent)
1 testBrowse 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.

1 test introduced at this concept.

Introduced code

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

1 file ranked by introduced lines: 83 introduced LOC across 13 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/agentHost/node/codex/codexAgent.ts 83 introduced LOC · 13 ranges

Open complete file

910
911 async authenticate(resource: string, token: string): Promise<boolean> {
912 > if (resource === this._gitHubEndpointService.getRepoResource().resource) { codexAgent.ts
913 return true;
914 }
915 > if (resource !== this._gitHubEndpointService.getCopilotResource().resource) { codexAgent.ts
916 return false;
917 }
918 > const changed = this._githubToken !== token; codexAgent.ts
919 > this._githubToken = token;
920 > if (this._usageSource === 'openai') {
921 void this._refreshProviderConfiguration();
922 return true;
923 }
924 > if (changed && this._connection.kind === 'ready' && this._connection.proxyHandle) { codexAgent.ts
925 // Codex stays running — proxy reads the new token from its
926 // own cell on the next request (Decision 4).
927 this._connection.proxyHandle.setToken(token);
928 this._queueModelRefresh();
929 > } else if (changed) { codexAgent.ts
930 > // Defer model refresh until the connection comes up.
931 > this._queueModelRefresh();
932 > }
933 > this._logService.info('[Codex] Auth token updated');
934 > void this._refreshProviderConfiguration();
935 > return true;
936 > }
937
938 /**
1029 */
1030 refreshModels(): Promise<void> {
1031 > return this._modelsRefreshPromise ?? this._queueModelRefresh(); codexAgent.ts
1032 > }
1033
1034 private _queueModelRefresh(): Promise<void> {
1035 > const refreshPromise = this._refreshModels().finally(() => { codexAgent.ts
1036 > if (this._modelsRefreshPromise === refreshPromise) {
1037 > this._modelsRefreshPromise = undefined;
1038 > }
1039 > });
1040 > this._modelsRefreshPromise = refreshPromise;
1041 > return refreshPromise;
1042 > }
1043
1044 private _ensureAuthenticated(): string | undefined {
1088
1089 private _createReasoningEffortConfigSchema(): ConfigSchema {
1090 > return { codexAgent.ts
1091 > type: 'object',
1092 > properties: {
1093 > [CODEX_THINKING_LEVEL_KEY]: {
1094 > type: 'string',
1095 > title: localize('codex.modelThinkingLevel.title', "Thinking Level"),
1096 > description: localize('codex.modelThinkingLevel.description', "Controls how much reasoning effort Codex uses."),
1097 > default: 'medium',
1098 > enum: [...CODEX_REASONING_EFFORTS],
1099 > enumLabels: CODEX_REASONING_EFFORTS.map(getReasoningEffortLabel),
1100 > enumDescriptions: CODEX_REASONING_EFFORTS.map(effort => getReasoningEffortDescription(effort) ?? ''),
1101 > },
1102 > },
1103 > };
1104 > }
1105
1106 private _getReasoningEffort(session: ICodexSession): ReasoningEffort | undefined {
1197
1198 private async _refreshModels(): Promise<void> {
1199 > const usageSource = this._usageSource; codexAgent.ts
1200 > if (usageSource === 'openai') {
1201 await this._refreshOpenAIModels();
1202 return;
1203 }
1204 > const token = this._githubToken; codexAgent.ts
1205 > if (!token) {
1206 this._models.set([], undefined);
1207 return;
1208 }
1209 > try { codexAgent.ts
1210 > const userAgent = `${USER_AGENT_PREFIX}/${this._productService.version}`;
1211 > const all = await this._copilotApiService.models(token, { headers: { 'User-Agent': userAgent }, suppressIntegrationId: true });
1212 > if (this._usageSource !== usageSource || this._githubToken !== token) {
1213 return;
1214 }
1215 > const configSchema = this._createReasoningEffortConfigSchema(); codexAgent.ts
1216 > // Codex talks to every model through the `vscode-proxy` custom model
1217 > // provider with `wire_api="responses"` (see CodexProxyService), so it
1218 > // can only drive models that expose Copilot CAPI's OpenAI-shaped
1219 > // Responses endpoint. Filter the catalog to those advertising
1220 > // `/responses` in `supported_endpoints` (this drops Anthropic
1221 > // `/v1/messages` and chat-completions-only models, which codex cannot
1222 > // use). The chosen id is forwarded straight through; CAPI remains the
1223 > // authority on what the token may actually use.
1224 > const models = all
1225 > .filter(m => m.supported_endpoints?.includes(CODEX_RESPONSES_ENDPOINT))
1226 > .sort((a, b) => Number(b.is_chat_default) - Number(a.is_chat_default))
1227 > .map((m): IAgentModelInfo => ({
1228 > provider: this.id,
1229 > id: m.id,
1230 > name: m.name ?? m.id,
1231 > maxContextWindow: m.capabilities?.limits?.max_context_window_tokens,
1232 > maxOutputTokens: m.capabilities?.limits?.max_output_tokens,
1233 > maxPromptTokens: m.capabilities?.limits?.max_prompt_tokens,
1234 > supportsVision: !!m.capabilities?.supports?.vision,
1235 > configSchema,
1236 > policyState: m.policy?.state as PolicyState | undefined,
1237 > _meta: createPricingMetaFromBilling(
1238 > normalizeCAPIBilling(m.billing),
1239 > typeof m.model_picker_price_category === 'string'
1240 ? m.model_picker_price_category
1241 > : undefined, codexAgent.ts
1242 > ),
1243 > }));
1244 > this._models.set(models, undefined);
1245 > } catch (err) {
1246 > this._logService.warn(`[Codex] Failed to refresh models: ${err instanceof Error ? err.message : String(err)}`);
1247 > // Keep the last known-good catalog. Usage-source changes clear the
1248 > // list in `_applyUsageSourceChange`; a transient periodic failure
1249 > // must not make every model disappear.
1250 > }
1251 > }
1252
1253 private async _refreshOpenAIModels(): Promise<void> {