agentHostGitHubEndpointService.ts ×9

Frontier kind: Code frontier

unlabeled · c_f8fe6606993f

1270 tests · 18949 LOC · 74 files · introduces 0 tests · 90 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
9 ranges90 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
1446 ranges18949 lines · 74 files · Browse complete extent
All tests (intent)
1270 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: 90 introduced LOC across 9 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/agentHost/node/agentHostGitHubEndpointService.ts 90 introduced LOC · 9 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- agentHostGitHubEndpointService.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 { Emitter, Event } from '../../../base/common/event.js';
7 > import { Disposable } from '../../../base/common/lifecycle.js';
8 > import { createDecorator } from '../../instantiation/common/instantiation.js';
9 > import { ILogService } from '../../log/common/log.js';
10 > import { AgentHostConfigKey, agentHostCustomizationConfigSchema } from '../common/agentHostCustomizationConfig.js';
11 > import { deriveGitHubEndpoints, gitHubCopilotResource, gitHubRepoResource, IGitHubEndpoints } from '../common/githubEndpoints.js';
12 > import { ProtectedResourceMetadata } from '../common/state/protocol/state.js';
13 > import { IAgentConfigurationService } from './agentConfigurationService.js';
14 >
15 > export const IAgentHostGitHubEndpointService = createDecorator<IAgentHostGitHubEndpointService>('agentHostGitHubEndpointService');
16 >
17 > /**
18 > * Single source of truth for the GitHub endpoints (protected resources + REST /
19 > * GraphQL hosts) the agent host talks to. Computed from the optional
20 > * `githubEnterpriseUri` root config so that every consumer — agent
21 > * `authenticate` / `getProtectedResources`, changeset operation `getAuthToken`
22 > * lookups, and the REST client — agrees on the same resource identifiers and API
23 > * base. With no enterprise URI configured, the values are byte-for-byte the
24 > * github.com defaults.
25 > */
26 > export interface IAgentHostGitHubEndpointService {
27 > readonly _serviceBrand: undefined;
28 >
29 > /**
30 > * Fires when the configured GitHub endpoints change (e.g. `githubEnterpriseUri`
31 > * was set, cleared, or repointed). Does NOT fire for unrelated root-config
32 > * changes.
33 > */
34 > readonly onDidChange: Event<void>;
35 >
36 > /** The GitHub Copilot protected resource, computed against the configured endpoints. */
37 > getCopilotResource(): ProtectedResourceMetadata;
38 >
39 > /** The GitHub repository protected resource, computed against the configured endpoints. */
40 > getRepoResource(): ProtectedResourceMetadata;
41 >
42 > /** The REST API base URI (no trailing slash), e.g. `https://api.github.com`. */
43 > getApiBaseUri(): string;
44 >
45 > /** The GraphQL endpoint URI, e.g. `https://api.github.com/graphql`. */
46 > getGraphQlUri(): string;
47 >
48 > /**
49 > * The configured GitHub Enterprise host (authority only, e.g. `acme.ghe.com`),
50 > * or `undefined` for github.com. Used to set `COPILOT_GH_HOST` for the Copilot CLI.
51 > */
52 > getEnterpriseHost(): string | undefined;
53 >
54 > /**
55 > * The raw configured GitHub Enterprise base URI (e.g. `https://acme.ghe.com`),
56 > * or `undefined` for github.com. This is the value the `@vscode/copilot-api`
57 > * `CAPIClient.updateDomains(..., enterpriseUrlConfig)` expects: it derives the
58 > * GitHub API host (`api.<host>`) used for `copilot_internal` endpoints (token
59 > * mint, etc.) from it. Distinct from {@link getApiBaseUri} (the already-derived
60 > * `api.` host) - the package does that derivation itself.
61 > */
62 > getEnterpriseUri(): string | undefined;
63 > }
64 >
65 > export class AgentHostGitHubEndpointService extends Disposable implements IAgentHostGitHubEndpointService {
66 >
67 > declare readonly _serviceBrand: undefined;
68 >
69 > private readonly _onDidChange = this._register(new Emitter<void>());
70 > readonly onDidChange = this._onDidChange.event;
71 >
72 > private _endpoints: IGitHubEndpoints;
73 > private _enterpriseUri: string | undefined;
74 >
75 > constructor(
76 @IAgentConfigurationService private readonly _configurationService: IAgentConfigurationService,
77 @ILogService private readonly _logService: ILogService,
96 }));
97 }
99 > private _resolve(): { endpoints: IGitHubEndpoints; enterpriseUri: string | undefined } {
100 const enterpriseUri = this._configurationService.getRootValue(agentHostCustomizationConfigSchema, AgentHostConfigKey.GithubEnterpriseUri);
101 return { endpoints: deriveGitHubEndpoints(enterpriseUri), enterpriseUri: enterpriseUri || undefined };
102 }
104 > getApiBaseUri(): string {
105 return this._endpoints.apiBaseUri;
106 }
108 > getGraphQlUri(): string {
109 return this._endpoints.graphQlUri;
110 }
112 > getEnterpriseHost(): string | undefined {
113 return this._endpoints.enterpriseHost;
114 }
116 > getEnterpriseUri(): string | undefined {
117 return this._enterpriseUri;
118 }
120 > getCopilotResource(): ProtectedResourceMetadata {
121 return gitHubCopilotResource(this._endpoints);
122 }
124 > getRepoResource(): ProtectedResourceMetadata {
125 return gitHubRepoResource(this._endpoints);
126 }