copilotAgent.ts ×16

Frontier kind: Code frontier

unlabeled · c_d0d2fee72611

82 tests · 51232 LOC · 300 files · introduces 0 tests · 56 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
16 ranges56 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
4856 ranges51232 lines · 300 files · Browse complete extent
All tests (intent)
82 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: 56 introduced LOC across 16 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/agentHost/node/copilot/copilotAgent.ts 56 introduced LOC · 16 ranges

Open complete file

191 }
192
193 > function toRestrictedTelemetryEndpoint(endpoint: string | undefined): string | undefined { copilotAgent.ts
194 > return endpoint ? `${endpoint.replace(/\/+$/, '')}/telemetry` : undefined;
195 > }
196
197 export { COPILOT_AGENT_HOST_SYSTEM_MESSAGE } from './prompts/systemMessage.js';
701
702 async authenticate(resource: string, token: string): Promise<boolean> {
703 > if (resource === this._gitHubEndpointService.getRepoResource().resource) { copilotAgent.ts
704 return true;
705 }
706 > if (resource !== this._gitHubEndpointService.getCopilotResource().resource) { copilotAgent.ts
707 return false;
708 }
709 > const tokenChanged = this._githubToken !== token; copilotAgent.ts
710 > this._githubToken = token;
711 > this._updateRestrictedTelemetry(token);
712 > this._logService.info(`[Copilot] Auth token ${tokenChanged ? 'updated' : 'unchanged'}`);
713 > if (tokenChanged) {
714 > await this._restartClientIfProxyChanged();
715 > void this._scheduleModelRefresh();
716 > }
717 > return true;
718 > }
719
720 async handleAuthenticationToken(params: AuthenticateParams): Promise<boolean> {
730
731 private _updateRestrictedTelemetry(githubToken: string | undefined): void {
732 > // Safe default synchronously: keep restricted/enhanced telemetry disabled until the minted copilotAgent.ts
733 > // CAPI Copilot session token confirms the `rt=1` opt-in. The GitHub token here carries no
734 > // `rt`/`tid` claims — those live in the Copilot session token, which the API service mints —
735 > // so the real values are resolved asynchronously below. Mirrors how the Copilot extension
736 > // reads `rt`/`tid` off its `CopilotToken` rather than the GitHub token.
737 > this._applyRestrictedTelemetry(undefined);
738 > if (githubToken) {
739 > void this._resolveRestrictedTelemetry(githubToken);
740 > }
741 > }
742
743 private async _resolveRestrictedTelemetry(githubToken: string): Promise<void> {
744 > try { copilotAgent.ts
745 > const ctx = await this._copilotApiService.resolveRestrictedTelemetryContext(githubToken);
746 > if (this._githubToken !== githubToken) {
747 return; // token changed while resolving; a newer call owns the state
748 }
749 > this._applyRestrictedTelemetry({ copilotAgent.ts
750 > ...ctx,
751 > telemetryEndpoint: toRestrictedTelemetryEndpoint(ctx.telemetryEndpoint),
752 > });
753 > } catch (err) {
754 this._logService.debug(`[Copilot] Restricted telemetry resolution failed: ${err instanceof Error ? err.message : String(err)}`);
755 }
756 > } copilotAgent.ts
757
758 private _applyRestrictedTelemetry(context: IRestrictedTelemetryContext | undefined): void {
759 > const rtEnabled = context?.restrictedTelemetryEnabled === true; copilotAgent.ts
760 > if (rtEnabled !== this._restrictedTelemetryEnabled) {
761 this._restrictedTelemetryEnabled = rtEnabled;
762 this._logService.info(`[Copilot] Enhanced (restricted) telemetry ${rtEnabled ? 'enabled for this account' : 'disabled'}`);
763 this._onDidChangeRestrictedTelemetry.fire();
764 }
765 > // Push the token-derived telemetry policy/identity to the restricted sender: `rt` gates copilotAgent.ts
766 > // enhanced GH telemetry (kept off for public users), `tid` becomes `copilot_trackingId`, and
767 > // the endpoint routes at the user's CAPI telemetry host (dotcom, GHE, or proxy).
768 > if (isAgentHostTelemetryService(this._telemetryService)) {
769 this._telemetryService.setRestrictedTelemetryEnabled(rtEnabled);
770 this._telemetryService.setCopilotTrackingId(context?.trackingId);
771 this._telemetryService.setRestrictedTelemetryEndpoint(context?.telemetryEndpoint);
772 }
773 > } copilotAgent.ts
774
775 private async _routeGitHubTelemetry(notification: GitHubTelemetryNotification): Promise<void> {
829 */
830 private _scheduleModelRefresh(): Promise<void> {
831 > const generation = ++this._modelCatalogGeneration; copilotAgent.ts
832 > if (this._scheduledModelRefresh) {
833 this._scheduledModelRefresh.generation = generation;
834 return this._scheduledModelRefresh.deferred.p;
835 }
837 > const scheduled = { deferred: new DeferredPromise<void>(), generation };
838 > this._scheduledModelRefresh = scheduled;
839 > this._modelRefreshSchedule.value = disposableTimeout(() => {
840 void (async () => {
841 try {
860 }
861 })();
862 > }, 0); copilotAgent.ts
863 > return scheduled.deferred.p;
864 > }
865
866 private _startModelRefresh(generation: number): Promise<void> {
2916 */
2917 private async _restartClientIfProxyChanged(): Promise<void> {
2918 > if (!this._client && !this._clientStarting) { copilotAgent.ts
2919 return;
2920 }
2936 return;
2937 }
2938 > this._logService.info(`[Copilot] CAPI proxy changed after token update (${oldProxy ?? '(none)'} -> ${newProxy ?? '(none)'}); restarting CopilotClient`); copilotAgent.ts
2939 > this._sessions.clearAndDisposeAll();
2940 > this._mcpNotificationSubs.clearAndDisposeAll();
2941 > await this._stopClient();
2942 > }
2943
2944 /**