420
421
constructor(
422
>
@ILogService private readonly _logService: ILogService,
copilotAgent.ts
423
>
@IInstantiationService private readonly _instantiationService: IInstantiationService,
424
>
@ISessionDataService private readonly _sessionDataService: ISessionDataService,
425
>
@IAgentHostGitService private readonly _gitService: IAgentHostGitService,
426
>
@IAgentConfigurationService private readonly _configurationService: IAgentConfigurationService,
427
>
@IAgentHostStateManager private readonly _stateManager: AgentHostStateManager,
428
>
@IAgentHostGitHubEndpointService private readonly _gitHubEndpointService: IAgentHostGitHubEndpointService,
429
>
@IAgentHostOTelService private readonly _otelService: IAgentHostOTelService,
430
>
@IAgentHostCompletions completions: IAgentHostCompletions,
431
>
@IAgentHostCheckpointService private readonly _checkpointService: IAgentHostCheckpointService,
432
>
@IAgentHostReviewService private readonly _reviewService: IAgentHostReviewService,
433
>
@INativeEnvironmentService private readonly _environmentService: INativeEnvironmentService,
434
>
@IByokLmBridgeRegistry private readonly _byokBridgeRegistry: IByokLmBridgeRegistry,
435
>
@ITelemetryService private readonly _telemetryService: ITelemetryService,
436
>
@ICopilotApiService private readonly _copilotApiService: ICopilotApiService,
437
>
@IAgentHostProxyResolver private readonly _proxyResolver: IAgentHostProxyResolver,
438
>
) {
439
>
super();
440
>
this._plugins = this._register(this._instantiationService.createInstance(PluginController, () => this._ensureClient()));
441
>
this._sessionLauncher = this._instantiationService.createInstance(CopilotSessionLauncher);
442
>
this._gitHubTelemetryForwarder = this._instantiationService.createInstance(CopilotGitHubTelemetryForwarder, () => this._restrictedTelemetryEnabled);
443
>
this._slashCommandProvider = new CopilotSlashCommandProvider(() => this._ensureClient().then(c => c.rpc.commands.list().then(c => c.commands)), this._logService);
444
>
this._githubTelemetryRouter = isAgentHostTelemetryService(this._telemetryService)
445
? new AgentHostGitHubTelemetryRouter(this._telemetryService)
446
: undefined;
447
>
this.onDidCustomizationsChange = this._plugins.onDidChange;
copilotAgent.ts
448
>
// Mirror the sub-agent fan-out signals onto the first-class spawned-
449
>
// chat channel so the orchestrator manages sub-agent chats
450
>
// through the same membership path as user-driven chats.
451
>
this._register(this._onDidSessionProgress.event(signal => this._emitSpawnedChatForSubagentSignal(signal)));
452
>
this._register(completions.registerProvider(new CopilotSlashCommandCompletionProvider(this.id,
453
>
{
454
>
isRubberDuckEnabled: () => this._isRubberDuckEnabled(),
455
>
getRuntimeSlashCommands: (sessionId, options) => this._getRuntimeSlashCommands(sessionId, options),
456
>
getSessionCustomizations: (sessionId) => this.getSessionCustomizations(AgentSession.uri(this.id, sessionId)),
457
>
getSessionConfigState: (sessionId) => this._getSessionConfigState(sessionId),
458
>
},
459
>
RUNTIME_SLASH_COMMAND_COMPLETION_WAIT_MS,
460
>
)));
461
>
462
>
// Restart the CLI client when a setting baked into the client/subprocess at
463
>
// startup changes, disposing any active sessions. These values are applied in
464
>
// `_ensureClient`, so they only take effect on the next client start.
465
>
this._register(this._configurationService.onDidRootConfigChange(() => {
466
this._restartClientIfStartupConfigChanged().catch(err =>
467
this._logService.error('[Copilot] Failed to apply root config change', err)
468
);
470
>
471
>
// Surface renderer BYOK models in the picker: republish them whenever the
472
>
// set of connected renderer bridges, or any renderer's models, change.
473
>
// The registry is only populated when `chat.agentHost.byokModels.enabled`
474
>
// is on, so this stays a no-op (empty list) while the feature is off.
475
>
this._register(this._byokBridgeRegistry.onDidChangeModels(() => {
476
this._logService.info('[Copilot] BYOK bridge changed; refreshing models');
477
this._refreshByokModels();
479
>
480
>
// `COPILOT_GH_HOST` is a subprocess env var (applied in `_ensureClient`) the
481
>
// CLI reads only at spawn time. When the configured GitHub Enterprise host
482
>
// changes - notably the startup race where the workbench pushes
483
>
// `githubEnterpriseUri` just after the client's initial spawn - restart the
484
>
// client so it comes up pointed at the right host. Driven off the endpoint
485
>
// service's `onDidChange` (which fires after its endpoints are recomputed)
486
>
// rather than the raw config event, so `getEnterpriseHost()` is current here.
487
>
this._register(this._gitHubEndpointService.onDidChange(() => {
488
this._restartClientIfStartupConfigChanged().catch(err =>
489
this._logService.error('[Copilot] Failed to restart client after endpoint change', err)
490
);
492
>
}
493
494
/**