codexProxyService.ts ×10

Frontier kind: Code frontier

unlabeled · c_9e47460bc47f

7 tests · 20571 LOC · 85 files · introduces 0 tests · 43 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
10 ranges43 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
1631 ranges20571 lines · 85 files · Browse complete extent
All tests (intent)
7 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.

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

src/vs/platform/agentHost/node/codex/codexProxyService.ts 43 introduced LOC · 10 ranges

Open complete file

163
164 constructor(
165 > @ILogService logService: ILogService, codexProxyService.ts
166 > @ICopilotApiService private readonly _copilotApiService: ICopilotApiService,
167 > ) {
168 > super(PROXY_USER_FACING_NAME, logService);
169 > }
170
171 protected createState(githubToken: string): ICodexProxyState {
172 > return { githubToken, lastPrimaryModel: undefined }; codexProxyService.ts
173 > }
174
175 async start(githubToken: string): Promise<ICodexProxyHandle> {
176 > const { runtime, release } = await this.acquire(githubToken); codexProxyService.ts
177 > // Most recent token wins for the runtime — single-tenant assumption.
178 > // Covers concurrent callers that awaited the same bind.
179 > runtime.state.githubToken = githubToken;
180 >
181 > let disposed = false;
182 > return {
183 > baseUrl: runtime.baseUrl,
184 > nonce: runtime.nonce,
185 > setToken: (newToken: string) => {
186 if (disposed) {
187 return;
192 runtime.state.githubToken = newToken;
193 },
194 > dispose: () => { codexProxyService.ts
195 > if (disposed) {
196 return;
197 }
198 > disposed = true; codexProxyService.ts
199 > release();
200 > },
201 > };
202 > }
203
204 protected override async handleRequest(
205 > req: http.IncomingMessage, codexProxyService.ts
206 > res: http.ServerResponse,
207 > runtime: ICodexProxyRuntime,
208 > ): Promise<void> {
209 > const method = req.method ?? 'GET';
210 > const pathname = new URL(req.url ?? '/', 'http://127.0.0.1').pathname;
211 > const incomingHeaders = Object.keys(req.headers).join(', ');
212 > this._logService.info(`[${PROXY_USER_FACING_NAME}] >>> ${method} ${pathname} (headers: ${incomingHeaders})`);
213 >
214 > if (method === 'GET' && pathname === '/') {
215 res.writeHead(200, { 'Content-Type': 'text/plain' });
216 res.end('ok');
217 return;
218 }
220 > // Codex CLI sends `Bearer <nonce>` — plain nonce, no sessionId suffix.
221 > const authHeader = req.headers['authorization'];
222 > const expected = `Bearer ${runtime.nonce}`;
223 > if (typeof authHeader !== 'string' || authHeader !== expected) {
224 writeJsonError(res, 401, 'authentication_error', 'Invalid authentication');
225 return;
226 }
228 > if (method === 'GET' && pathname === '/v1/models') {
229 // The Codex endpoint expects its own rich `ModelsResponse` schema, not
230 // CAPI's model shape. VS Code already owns CAPI model discovery and
239 // Codex sends `/v1/responses`, `//responses` (when base_url ends in `/`),
240 // or plain `/responses`. Accept all three.
241 > if (method === 'POST' && (pathname === '/v1/responses' || pathname === '/responses' || pathname === '//responses')) { codexProxyService.ts
242 await this._handleResponses(req, res, runtime);
243 return;
245
246 writeJsonError(res, 404, 'not_found_error', `No route for ${method} ${pathname}`);
248
249 private async _handleResponses(