441
442
constructor(
443
>
@ILogService private readonly _logService: ILogService,
claudeAgent.ts
444
>
@ICopilotApiService private readonly _copilotApiService: ICopilotApiService,
445
>
@IClaudeProxyService private readonly _claudeProxyService: IClaudeProxyService,
446
>
@IClaudeAgentSdkService private readonly _sdkService: IClaudeAgentSdkService,
447
>
@IAgentHostStateManager private readonly _stateManager: AgentHostStateManager,
448
>
@IAgentHostGitService private readonly _gitService: IAgentHostGitService,
449
>
@IAgentConfigurationService private readonly _configurationService: IAgentConfigurationService,
450
>
@IAgentHostGitHubEndpointService private readonly _gitHubEndpointService: IAgentHostGitHubEndpointService,
451
>
@IInstantiationService private readonly _instantiationService: IInstantiationService,
452
>
@IAgentPluginManager private readonly _pluginManager: IAgentPluginManager,
453
>
@IProductService private readonly _productService: IProductService,
454
>
@INativeEnvironmentService private readonly _environmentService: INativeEnvironmentService,
455
>
) {
456
>
super();
457
>
this._metadataStore = _instantiationService.createInstance(ClaudeSessionMetadataStore, this.id);
458
>
// CAPI reports each request's billed credits via the proxy (the SDK
459
>
// strips `copilot_usage` from its `result`). Route every report to
460
>
// the originating session by the session id the proxy decoded from
461
>
// the Bearer token, so the session can surface real per-turn credits.
462
>
this._register(this._claudeProxyService.onDidReportCredits(e => {
463
this._findSessionBySdkId(e.sessionId)?.recordTurnCredits(e.totalNanoAiu);
465
>
466
>
// Phase 19: resolve the transport mode now and re-resolve reactively.
467
>
// A flip only affects sessions materialized afterwards; in-flight
468
>
// subprocesses keep their original transport. When native, kick off an
469
>
// initial model refresh since no GitHub auth (which would otherwise
470
>
// trigger it) is required.
471
>
this._transportMode = this._resolveTransportMode();
472
>
this._register(this._configurationService.onDidRootConfigChange(() => {
473
const next = this._resolveTransportMode();
474
if (next !== this._transportMode) {