agentHostProxyResolver.ts ×9

Frontier kind: Code frontier

unlabeled · c_e1bab80cf9e9

177 tests · 11850 LOC · 59 files · introduces 0 tests · 69 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
9 ranges69 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
1784 ranges11850 lines · 59 files · Browse complete extent
All tests (intent)
177 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: 69 introduced LOC across 9 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/agentHost/node/agentHostProxyResolver.ts 69 introduced LOC · 9 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- agentHostProxyResolver.ts
2 > * Copyright (c) Microsoft Corporation. All rights reserved.
3 > * Licensed under the MIT License. See License.txt in the project root for license information.
4 > *--------------------------------------------------------------------------------------------*/
5 >
6 > import { LogLevel as ProxyLogLevel, ProxyAgentParams, ProxySupportSetting, createFetchPatch, createProxyAuthorizationLookup, createProxyResolver, loadSystemCertificates } from '@vscode/proxy-agent';
7 > import { IDisposable, toDisposable } from '../../../base/common/lifecycle.js';
8 > import { IConfigurationService } from '../../configuration/common/configuration.js';
9 > import { createDecorator } from '../../instantiation/common/instantiation.js';
10 > import { ILogService, LogLevel } from '../../log/common/log.js';
11 > import { AuthInfo, Credentials, systemCertificatesNodeDefault } from '../../request/common/request.js';
12 > import { IAgentHostClientProxyConnection } from '../common/agentHostClientProxyChannel.js';
13 >
14 > export const IAgentHostProxyResolver = createDecorator<IAgentHostProxyResolver>('agentHostProxyResolver');
15 >
16 > /**
17 > * Node-side registry of renderer {@link IAgentHostClientProxyConnection}s keyed
18 > * by client id. Populated by the agent host's connection lifecycle (one entry
19 > * per connected renderer) and consumed by {@link CopilotAgent} to resolve the
20 > * CAPI proxy through VS Code's Electron session before spawning the Copilot SDK.
21 > *
22 > * Proxy configuration is a property of the machine, not of a particular window,
23 > * so any connected renderer can serve the lookup; the resolver calls the first
24 > * available connection and falls through to the next on failure.
25 > */
26 > export interface IAgentHostProxyResolver {
27 > readonly _serviceBrand: undefined;
28 >
29 > /** Register a renderer connection. Disposing the result removes it. */
30 > register(clientId: string, connection: IAgentHostClientProxyConnection): IDisposable;
31 >
32 > /**
33 > * Resolve the proxy URL for `url` (e.g. `http://host:port`), or `undefined`
34 > * for a direct connection. Reuses `@vscode/proxy-agent`'s `resolveProxyURL`
35 > * so the same precedence as the rest of VS Code applies: `http.noProxy` →
36 > * `http.proxy` setting → `HTTP(S)_PROXY` env vars → the host proxy resolution
37 > * that runs in VS Code (Electron session) via the reverse channel.
38 > */
39 > resolveProxy(url: string): Promise<string | undefined>;
40 >
41 > /** Fetch using the same proxy, certificate, and host/PAC resolution as {@link resolveProxy}. */
42 > fetch(input: string | URL | Request, init?: RequestInit): Promise<Response>;
43 > }
44 >
45 > export class AgentHostProxyResolver implements IAgentHostProxyResolver {
46 >
47 > declare readonly _serviceBrand: undefined;
48 >
49 > private readonly _connections = new Map<string, IAgentHostClientProxyConnection>();
50 > private _proxyResolver: ReturnType<typeof createProxyResolver> | undefined;
51 > private _proxyAgentParams: ProxyAgentParams | undefined;
52 > private _fetch: typeof globalThis.fetch | undefined;
53 >
54 > constructor(
55 @IConfigurationService private readonly _configurationService: IConfigurationService,
56 @ILogService private readonly _logService: ILogService,
57 ) { }
59 > register(clientId: string, connection: IAgentHostClientProxyConnection): IDisposable {
60 this._connections.set(clientId, connection);
61 return toDisposable(() => {
65 });
66 }
68 > resolveProxy(url: string): Promise<string | undefined> {
69 return this._getProxyResolver().resolveProxyURL(url);
70 }
72 > fetch(input: string | URL | Request, init?: RequestInit): Promise<Response> {
73 if (!this._fetch) {
74 const proxyResolver = this._getProxyResolver();
77 return this._fetch(input, init);
78 }
80 > private _getProxyResolver(): ReturnType<typeof createProxyResolver> {
81 if (!this._proxyResolver) {
82 // Mirror `workbench/api/node/proxyResolver.ts`.
132 return this._proxyResolver;
133 }
135 > private async _hostResolveProxy(url: string): Promise<string | undefined> {
136 for (const connection of this._connections.values()) {
137 try {
143 return undefined;
144 }
146 > private async _hostLookupAuthorization(authInfo: AuthInfo): Promise<Credentials | undefined> {
147 for (const connection of this._connections.values()) {
148 try {
154 return undefined;
155 }
157 > private async _hostLookupKerberosAuthorization(url: string): Promise<string | undefined> {
158 for (const connection of this._connections.values()) {
159 try {