diff --git a/extensions/copilot/src/extension/byok/node/openAIEndpoint.ts b/extensions/copilot/src/extension/byok/node/openAIEndpoint.ts index 20b52ffd899..f5d18c51af5 100644 --- a/extensions/copilot/src/extension/byok/node/openAIEndpoint.ts +++ b/extensions/copilot/src/extension/byok/node/openAIEndpoint.ts @@ -11,7 +11,6 @@ import { ICAPIClientService } from '../../../platform/endpoint/common/capiClient import { IDomainService } from '../../../platform/endpoint/common/domainService'; import { IChatModelInformation } from '../../../platform/endpoint/common/endpointProvider'; import { ChatEndpoint } from '../../../platform/endpoint/node/chatEndpoint'; -import { IEnvService } from '../../../platform/env/common/envService'; import { ILogService } from '../../../platform/log/common/logService'; import { isOpenAiFunctionTool } from '../../../platform/networking/common/fetch'; import { IFetcherService } from '../../../platform/networking/common/fetcherService'; @@ -52,7 +51,6 @@ export class OpenAIEndpoint extends ChatEndpoint { @IFetcherService fetcherService: IFetcherService, @IDomainService domainService: IDomainService, @ICAPIClientService capiClientService: ICAPIClientService, - @IEnvService envService: IEnvService, @ITelemetryService telemetryService: ITelemetryService, @IAuthenticationService authService: IAuthenticationService, @IChatMLFetcher chatMLFetcher: IChatMLFetcher, @@ -67,7 +65,6 @@ export class OpenAIEndpoint extends ChatEndpoint { domainService, capiClientService, fetcherService, - envService, telemetryService, authService, chatMLFetcher, diff --git a/extensions/copilot/src/extension/log/vscode-node/loggingActions.ts b/extensions/copilot/src/extension/log/vscode-node/loggingActions.ts index f321d3f15ae..94e1552b0df 100644 --- a/extensions/copilot/src/extension/log/vscode-node/loggingActions.ts +++ b/extensions/copilot/src/extension/log/vscode-node/loggingActions.ts @@ -14,7 +14,6 @@ import { RequestType } from '@vscode/copilot-api'; import { IAuthenticationService } from '../../../platform/authentication/common/authentication'; import { ConfigKey, IConfigurationService } from '../../../platform/configuration/common/configurationService'; import { ICAPIClientService } from '../../../platform/endpoint/common/capiClient'; -import { IDomainService } from '../../../platform/endpoint/common/domainService'; import { CAPIClientImpl } from '../../../platform/endpoint/node/capiClientImpl'; import { IEnvService, isScenarioAutomation } from '../../../platform/env/common/envService'; import { IVSCodeExtensionContext } from '../../../platform/extContext/common/extensionContext'; @@ -361,7 +360,6 @@ export function collectFetcherTelemetry(accessor: ServicesAccessor, error: any): const fetcherService = accessor.get(IFetcherService); const envService = accessor.get(IEnvService); const telemetryService = accessor.get(ITelemetryService); - const domainService = accessor.get(IDomainService); const logService = accessor.get(ILogService); const authService = accessor.get(IAuthenticationService); const configurationService = accessor.get(IConfigurationService); @@ -427,9 +425,7 @@ export function collectFetcherTelemetry(accessor: ServicesAccessor, error: any): const modifiedCapiClientService = modifiedInstaService.createInstance(CAPIClientImpl); const response = await getRequest( fetcher, - envService, telemetryService, - domainService, modifiedCapiClientService, { type: RequestType.Models }, copilotToken, diff --git a/extensions/copilot/src/extension/prompt/node/chatMLFetcher.ts b/extensions/copilot/src/extension/prompt/node/chatMLFetcher.ts index 1533ed21fce..5bc7b56f0d7 100644 --- a/extensions/copilot/src/extension/prompt/node/chatMLFetcher.ts +++ b/extensions/copilot/src/extension/prompt/node/chatMLFetcher.ts @@ -5,17 +5,11 @@ import { Raw } from '@vscode/prompt-tsx'; import type { CancellationToken } from 'vscode'; -import { IAuthenticationService } from '../../../platform/authentication/common/authentication'; import { FetchStreamRecorder, IChatMLFetcher, IFetchMLOptions, Source } from '../../../platform/chat/common/chatMLFetcher'; -import { IChatQuotaService } from '../../../platform/chat/common/chatQuotaService'; import { ChatFetchError, ChatFetchResponseType, ChatFetchRetriableError, ChatLocation, ChatResponse, ChatResponses } from '../../../platform/chat/common/commonTypes'; import { IConversationOptions } from '../../../platform/chat/common/conversationOptions'; import { getTextPart, toTextParts } from '../../../platform/chat/common/globalStringUtils'; -import { IInteractionService } from '../../../platform/chat/common/interactionService'; import { HARD_TOOL_LIMIT } from '../../../platform/configuration/common/configurationService'; -import { ICAPIClientService } from '../../../platform/endpoint/common/capiClient'; -import { IDomainService } from '../../../platform/endpoint/common/domainService'; -import { IEnvService } from '../../../platform/env/common/envService'; import { ILogService } from '../../../platform/log/common/logService'; import { OptionalChatRequestParams } from '../../../platform/networking/common/fetch'; import { IFetcherService } from '../../../platform/networking/common/fetcherService'; @@ -30,6 +24,7 @@ import * as errorsUtil from '../../../util/common/errors'; import { isCancellationError } from '../../../util/vs/base/common/errors'; import { Emitter } from '../../../util/vs/base/common/event'; import { generateUuid } from '../../../util/vs/base/common/uuid'; +import { IInstantiationService } from '../../../util/vs/platform/instantiation/common/instantiation'; import { OpenAIEndpoint } from '../../byok/node/openAIEndpoint'; import { EXTENSION_ID } from '../../common/constants'; @@ -85,12 +80,7 @@ export class ChatMLFetcherImpl extends AbstractChatMLFetcher { @ITelemetryService private readonly _telemetryService: ITelemetryService, @IRequestLogger private readonly _requestLogger: IRequestLogger, @ILogService private readonly _logService: ILogService, - @IEnvService private readonly _envService: IEnvService, - @IDomainService private readonly _domainService: IDomainService, - @ICAPIClientService private readonly _capiClientService: ICAPIClientService, - @IAuthenticationService private readonly _authenticationService: IAuthenticationService, - @IInteractionService private readonly _interactionService: IInteractionService, - @IChatQuotaService private readonly _chatQuotaService: IChatQuotaService, + @IInstantiationService private readonly _instantiationService: IInstantiationService, @IConversationOptions options: IConversationOptions, ) { super(options); @@ -158,16 +148,8 @@ export class ChatMLFetcherImpl extends AbstractChatMLFetcher { reason: payloadValidationResult.reason, }; } else { - response = await fetchAndStreamChat( - this._logService, - this._telemetryService, - this._fetcherService, - this._envService, - this._chatQuotaService, - this._domainService, - this._capiClientService, - this._authenticationService, - this._interactionService, + response = await this._instantiationService.invokeFunction(accessor => fetchAndStreamChat( + accessor, chatEndpoint, requestBody, baseTelemetry, @@ -179,7 +161,7 @@ export class ChatMLFetcherImpl extends AbstractChatMLFetcher { userInitiatedRequest, token, telemetryProperties - ); + )); tokenCount = await chatEndpoint.acquireTokenizer().countMessagesTokens(messages); const extensionId = source?.extensionId ?? EXTENSION_ID; this._onDidMakeChatMLRequest.fire({ diff --git a/extensions/copilot/src/extension/prompt/vscode-node/endpointProviderImpl.ts b/extensions/copilot/src/extension/prompt/vscode-node/endpointProviderImpl.ts index 33914978c8b..99e5c2dfb88 100644 --- a/extensions/copilot/src/extension/prompt/vscode-node/endpointProviderImpl.ts +++ b/extensions/copilot/src/extension/prompt/vscode-node/endpointProviderImpl.ts @@ -9,7 +9,6 @@ import { ConfigKey, IConfigurationService } from '../../../platform/configuratio import { AutoChatEndpoint } from '../../../platform/endpoint/common/autoChatEndpoint'; import { IAutomodeService } from '../../../platform/endpoint/common/automodeService'; import { ICAPIClientService } from '../../../platform/endpoint/common/capiClient'; -import { IDomainService } from '../../../platform/endpoint/common/domainService'; import { ChatEndpointFamily, IChatModelInformation, ICompletionModelInformation, IEndpointProvider } from '../../../platform/endpoint/common/endpointProvider'; import { CopilotChatEndpoint } from '../../../platform/endpoint/node/copilotChatEndpoint'; import { IModelMetadataFetcher, ModelMetadataFetcher } from '../../../platform/endpoint/node/modelMetadataFetcher'; @@ -35,7 +34,6 @@ export class ProductionEndpointProvider implements IEndpointProvider { constructor( collectFetcherTelemetry: (accessor: ServicesAccessor, error: any) => void, - @IDomainService domainService: IDomainService, @ICAPIClientService capiClientService: ICAPIClientService, @IFetcherService fetcher: IFetcherService, @IAutomodeService private readonly _autoModeService: IAutomodeService, @@ -54,7 +52,6 @@ export class ProductionEndpointProvider implements IEndpointProvider { false, fetcher, _requestLogger, - domainService, capiClientService, this._configService, this._expService, diff --git a/extensions/copilot/src/extension/xtab/node/xtabEndpoint.ts b/extensions/copilot/src/extension/xtab/node/xtabEndpoint.ts index 4063c1dd8a8..d467f61e75c 100644 --- a/extensions/copilot/src/extension/xtab/node/xtabEndpoint.ts +++ b/extensions/copilot/src/extension/xtab/node/xtabEndpoint.ts @@ -10,7 +10,6 @@ import { ICAPIClientService } from '../../../platform/endpoint/common/capiClient import { IDomainService } from '../../../platform/endpoint/common/domainService'; import { IChatModelInformation } from '../../../platform/endpoint/common/endpointProvider'; import { ChatEndpoint } from '../../../platform/endpoint/node/chatEndpoint'; -import { IEnvService } from '../../../platform/env/common/envService'; import { ILogService } from '../../../platform/log/common/logService'; import { IFetcherService } from '../../../platform/networking/common/fetcherService'; import { IExperimentationService } from '../../../platform/telemetry/common/nullExperimentationService'; @@ -55,7 +54,6 @@ export class XtabEndpoint extends ChatEndpoint { @IDomainService _domainService: IDomainService, @IFetcherService _fetcherService: IFetcherService, @ICAPIClientService _capiClientService: ICAPIClientService, - @IEnvService _envService: IEnvService, @ITelemetryService _telemetryService: ITelemetryService, @IAuthenticationService _authService: IAuthenticationService, @IChatMLFetcher _chatMLFetcher: IChatMLFetcher, @@ -70,7 +68,6 @@ export class XtabEndpoint extends ChatEndpoint { _domainService, _capiClientService, _fetcherService, - _envService, _telemetryService, _authService, _chatMLFetcher, diff --git a/extensions/copilot/src/platform/chunking/common/chunkingEndpointClientImpl.ts b/extensions/copilot/src/platform/chunking/common/chunkingEndpointClientImpl.ts index 1cf0bd21002..8797e8c17b9 100644 --- a/extensions/copilot/src/platform/chunking/common/chunkingEndpointClientImpl.ts +++ b/extensions/copilot/src/platform/chunking/common/chunkingEndpointClientImpl.ts @@ -18,7 +18,6 @@ import { Range } from '../../../util/vs/editor/common/core/range'; import { IInstantiationService } from '../../../util/vs/platform/instantiation/common/instantiation'; import { Embedding, EmbeddingType, EmbeddingVector } from '../../embeddings/common/embeddingsComputer'; import { ICAPIClientService } from '../../endpoint/common/capiClient'; -import { IDomainService } from '../../endpoint/common/domainService'; import { IEnvService } from '../../env/common/envService'; import { logExecTime } from '../../log/common/logExecTime'; import { ILogService } from '../../log/common/logService'; @@ -300,7 +299,6 @@ export class ChunkingEndpointClientImpl extends Disposable implements IChunkingE constructor( @IInstantiationService instantiationService: IInstantiationService, - @IDomainService private readonly _domainService: IDomainService, @ICAPIClientService private readonly _capiClientService: ICAPIClientService, @IEnvService private readonly _envService: IEnvService, @IFetcherService private readonly _fetcherService: IFetcherService, @@ -346,9 +344,7 @@ export class ChunkingEndpointClientImpl extends Disposable implements IChunkingE const makeRequest = async (attempt: number) => { return logExecTime(this._logService, `ChunksEndpointEmbeddingComputer.fetchChunksRequest(${content.uri}, attempt=${attempt})`, () => postRequest( this._fetcherService, - this._envService, this._telemetryService, - this._domainService, this._capiClientService, { type: RequestType.Chunks }, authToken, diff --git a/extensions/copilot/src/platform/embeddings/common/remoteEmbeddingsComputer.ts b/extensions/copilot/src/platform/embeddings/common/remoteEmbeddingsComputer.ts index 93efcdadb7d..83ec4c77641 100644 --- a/extensions/copilot/src/platform/embeddings/common/remoteEmbeddingsComputer.ts +++ b/extensions/copilot/src/platform/embeddings/common/remoteEmbeddingsComputer.ts @@ -12,7 +12,6 @@ import { generateUuid } from '../../../util/vs/base/common/uuid'; import { IAuthenticationService } from '../../authentication/common/authentication'; import { getGithubMetadataHeaders } from '../../chunking/common/chunkingEndpointClientImpl'; import { ICAPIClientService } from '../../endpoint/common/capiClient'; -import { IDomainService } from '../../endpoint/common/domainService'; import { IEnvService } from '../../env/common/envService'; import { logExecTime } from '../../log/common/logExecTime'; import { ILogService } from '../../log/common/logService'; @@ -31,7 +30,6 @@ export class RemoteEmbeddingsComputer implements IEmbeddingsComputer { constructor( @IAuthenticationService private readonly _authService: IAuthenticationService, @ICAPIClientService private readonly _capiClientService: ICAPIClientService, - @IDomainService private readonly _domainService: IDomainService, @IEnvService private readonly _envService: IEnvService, @IFetcherService private readonly _fetcherService: IFetcherService, @ILogService private readonly _logService: ILogService, @@ -69,9 +67,7 @@ export class RemoteEmbeddingsComputer implements IEmbeddingsComputer { }; const response = await postRequest( this._fetcherService, - this._envService, this._telemetryService, - this._domainService, this._capiClientService, { type: RequestType.DotcomEmbeddings }, token, diff --git a/extensions/copilot/src/platform/endpoint/node/chatEndpoint.ts b/extensions/copilot/src/platform/endpoint/node/chatEndpoint.ts index 9b8aaaeed0c..504dabb3223 100644 --- a/extensions/copilot/src/platform/endpoint/node/chatEndpoint.ts +++ b/extensions/copilot/src/platform/endpoint/node/chatEndpoint.ts @@ -16,7 +16,6 @@ import { IChatMLFetcher, Source } from '../../chat/common/chatMLFetcher'; import { ChatLocation, ChatResponse } from '../../chat/common/commonTypes'; import { getTextPart } from '../../chat/common/globalStringUtils'; import { CHAT_MODEL, ConfigKey, IConfigurationService } from '../../configuration/common/configurationService'; -import { IEnvService } from '../../env/common/envService'; import { ILogService } from '../../log/common/logService'; import { FinishedCallback, ICopilotToolCall, OptionalChatRequestParams } from '../../networking/common/fetch'; import { IFetcherService, Response } from '../../networking/common/fetcherService'; @@ -165,7 +164,6 @@ export class ChatEndpoint implements IChatEndpoint { @IDomainService protected readonly _domainService: IDomainService, @ICAPIClientService private readonly _capiClientService: ICAPIClientService, @IFetcherService private readonly _fetcherService: IFetcherService, - @IEnvService private readonly _envService: IEnvService, @ITelemetryService private readonly _telemetryService: ITelemetryService, @IAuthenticationService private readonly _authService: IAuthenticationService, @IChatMLFetcher private readonly _chatMLFetcher: IChatMLFetcher, @@ -305,9 +303,7 @@ export class ChatEndpoint implements IChatEndpoint { try { const response = await postRequest( this._fetcherService, - this._envService, this._telemetryService, - this._domainService, this._capiClientService, { type: RequestType.ModelPolicy, modelId: this.model }, (await this._authService.getCopilotToken()).token, @@ -388,7 +384,6 @@ export class RemoteAgentChatEndpoint extends ChatEndpoint { @IDomainService domainService: IDomainService, @ICAPIClientService capiClientService: ICAPIClientService, @IFetcherService fetcherService: IFetcherService, - @IEnvService envService: IEnvService, @ITelemetryService telemetryService: ITelemetryService, @IAuthenticationService authService: IAuthenticationService, @IChatMLFetcher chatMLFetcher: IChatMLFetcher, @@ -403,7 +398,6 @@ export class RemoteAgentChatEndpoint extends ChatEndpoint { domainService, capiClientService, fetcherService, - envService, telemetryService, authService, chatMLFetcher, diff --git a/extensions/copilot/src/platform/endpoint/node/copilotChatEndpoint.ts b/extensions/copilot/src/platform/endpoint/node/copilotChatEndpoint.ts index e084cad96c9..b645af53fd9 100644 --- a/extensions/copilot/src/platform/endpoint/node/copilotChatEndpoint.ts +++ b/extensions/copilot/src/platform/endpoint/node/copilotChatEndpoint.ts @@ -40,7 +40,6 @@ export class CopilotChatEndpoint extends ChatEndpoint { domainService, capiClientService, fetcherService, - envService, telemetryService, authService, chatMLFetcher, diff --git a/extensions/copilot/src/platform/endpoint/node/modelMetadataFetcher.ts b/extensions/copilot/src/platform/endpoint/node/modelMetadataFetcher.ts index 34586d2aff3..346d0c77250 100644 --- a/extensions/copilot/src/platform/endpoint/node/modelMetadataFetcher.ts +++ b/extensions/copilot/src/platform/endpoint/node/modelMetadataFetcher.ts @@ -20,7 +20,6 @@ import { IRequestLogger } from '../../requestLogger/node/requestLogger'; import { IExperimentationService } from '../../telemetry/common/nullExperimentationService'; import { ITelemetryService } from '../../telemetry/common/telemetry'; import { ICAPIClientService } from '../common/capiClient'; -import { IDomainService } from '../common/domainService'; import { ChatEndpointFamily, IChatModelInformation, ICompletionModelInformation, IModelAPIResponse, isChatModelInformation, isCompletionModelInformation } from '../common/endpointProvider'; import { getMaxPromptTokens } from './chatEndpoint'; @@ -80,7 +79,6 @@ export class ModelMetadataFetcher implements IModelMetadataFetcher { protected readonly _isModelLab: boolean, @IFetcherService private readonly _fetcher: IFetcherService, @IRequestLogger private readonly _requestLogger: IRequestLogger, - @IDomainService private readonly _domainService: IDomainService, @ICAPIClientService private readonly _capiClientService: ICAPIClientService, @IConfigurationService private readonly _configService: IConfigurationService, @IExperimentationService private readonly _expService: IExperimentationService, @@ -219,9 +217,7 @@ export class ModelMetadataFetcher implements IModelMetadataFetcher { try { const response = await getRequest( this._fetcher, - this._envService, this._telemetryService, - this._domainService, this._capiClientService, requestMetadata, copilotToken, @@ -284,9 +280,7 @@ export class ModelMetadataFetcher implements IModelMetadataFetcher { try { const response = await getRequest( this._fetcher, - this._envService, this._telemetryService, - this._domainService, this._capiClientService, requestMetadata, copilotToken, diff --git a/extensions/copilot/src/platform/endpoint/node/proxy4oEndpoint.ts b/extensions/copilot/src/platform/endpoint/node/proxy4oEndpoint.ts index df4036b4ffd..c013b89afc4 100644 --- a/extensions/copilot/src/platform/endpoint/node/proxy4oEndpoint.ts +++ b/extensions/copilot/src/platform/endpoint/node/proxy4oEndpoint.ts @@ -10,7 +10,7 @@ import { IInstantiationService } from '../../../util/vs/platform/instantiation/c import { IAuthenticationService } from '../../authentication/common/authentication'; import { IChatMLFetcher } from '../../chat/common/chatMLFetcher'; import { CHAT_MODEL, ConfigKey, IConfigurationService } from '../../configuration/common/configurationService'; -import { IEnvService } from '../../env/common/envService'; +import { ILogService } from '../../log/common/logService'; import { IFetcherService } from '../../networking/common/fetcherService'; import { IExperimentationService } from '../../telemetry/common/nullExperimentationService'; import { ITokenizerProvider } from '../../tokenizer/node/tokenizer'; @@ -18,7 +18,6 @@ import { ICAPIClientService } from '../common/capiClient'; import { IDomainService } from '../common/domainService'; import { IChatModelInformation } from '../common/endpointProvider'; import { ChatEndpoint } from './chatEndpoint'; -import { ILogService } from '../../log/common/logService'; export class Proxy4oEndpoint extends ChatEndpoint { @@ -28,7 +27,6 @@ export class Proxy4oEndpoint extends ChatEndpoint { @IDomainService domainService: IDomainService, @ICAPIClientService capiClientService: ICAPIClientService, @IFetcherService fetcherService: IFetcherService, - @IEnvService envService: IEnvService, @ITelemetryService telemetryService: ITelemetryService, @IAuthenticationService private readonly authService: IAuthenticationService, @IChatMLFetcher chatMLFetcher: IChatMLFetcher, @@ -63,7 +61,6 @@ export class Proxy4oEndpoint extends ChatEndpoint { domainService, capiClientService, fetcherService, - envService, telemetryService, authService, chatMLFetcher, diff --git a/extensions/copilot/src/platform/endpoint/node/proxyInstantApplyShortEndpoint.ts b/extensions/copilot/src/platform/endpoint/node/proxyInstantApplyShortEndpoint.ts index f16efba6996..1fcc7b0a651 100644 --- a/extensions/copilot/src/platform/endpoint/node/proxyInstantApplyShortEndpoint.ts +++ b/extensions/copilot/src/platform/endpoint/node/proxyInstantApplyShortEndpoint.ts @@ -9,7 +9,7 @@ import { IInstantiationService } from '../../../util/vs/platform/instantiation/c import { IAuthenticationService } from '../../authentication/common/authentication'; import { IChatMLFetcher } from '../../chat/common/chatMLFetcher'; import { CHAT_MODEL, ConfigKey, IConfigurationService } from '../../configuration/common/configurationService'; -import { IEnvService } from '../../env/common/envService'; +import { ILogService } from '../../log/common/logService'; import { IFetcherService } from '../../networking/common/fetcherService'; import { IExperimentationService } from '../../telemetry/common/nullExperimentationService'; import { ITelemetryService } from '../../telemetry/common/telemetry'; @@ -18,7 +18,6 @@ import { ICAPIClientService } from '../common/capiClient'; import { IDomainService } from '../common/domainService'; import { IChatModelInformation } from '../common/endpointProvider'; import { ChatEndpoint } from './chatEndpoint'; -import { ILogService } from '../../log/common/logService'; export class ProxyInstantApplyShortEndpoint extends ChatEndpoint { @@ -26,7 +25,6 @@ export class ProxyInstantApplyShortEndpoint extends ChatEndpoint { @IDomainService domainService: IDomainService, @ICAPIClientService capiClientService: ICAPIClientService, @IFetcherService fetcherService: IFetcherService, - @IEnvService envService: IEnvService, @ITelemetryService telemetryService: ITelemetryService, @IAuthenticationService private readonly authService: IAuthenticationService, @IChatMLFetcher chatMLFetcher: IChatMLFetcher, @@ -60,7 +58,6 @@ export class ProxyInstantApplyShortEndpoint extends ChatEndpoint { domainService, capiClientService, fetcherService, - envService, telemetryService, authService, chatMLFetcher, diff --git a/extensions/copilot/src/platform/endpoint/test/node/azureEndpoint.ts b/extensions/copilot/src/platform/endpoint/test/node/azureEndpoint.ts index 956ffee2723..192dda8c643 100644 --- a/extensions/copilot/src/platform/endpoint/test/node/azureEndpoint.ts +++ b/extensions/copilot/src/platform/endpoint/test/node/azureEndpoint.ts @@ -8,7 +8,6 @@ import { IInstantiationService } from '../../../../util/vs/platform/instantiatio import { IAuthenticationService } from '../../../authentication/common/authentication'; import { IChatMLFetcher } from '../../../chat/common/chatMLFetcher'; import { CHAT_MODEL, IConfigurationService } from '../../../configuration/common/configurationService'; -import { IEnvService } from '../../../env/common/envService'; import { ILogService } from '../../../log/common/logService'; import { IFetcherService } from '../../../networking/common/fetcherService'; import { IChatEndpoint, IEndpointBody } from '../../../networking/common/networking'; @@ -28,7 +27,6 @@ export class AzureTestEndpoint extends ChatEndpoint { @IDomainService domainService: IDomainService, @ICAPIClientService capiClient: ICAPIClientService, @IFetcherService fetcherService: IFetcherService, - @IEnvService envService: IEnvService, @ITelemetryService telemetryService: ITelemetryService, @IAuthenticationService authService: IAuthenticationService, @IChatMLFetcher chatMLFetcher: IChatMLFetcher, @@ -61,7 +59,6 @@ export class AzureTestEndpoint extends ChatEndpoint { domainService, capiClient, fetcherService, - envService, telemetryService, authService, chatMLFetcher, diff --git a/extensions/copilot/src/platform/endpoint/test/node/capiEndpoint.ts b/extensions/copilot/src/platform/endpoint/test/node/capiEndpoint.ts index a173fac56b4..87e491adf80 100644 --- a/extensions/copilot/src/platform/endpoint/test/node/capiEndpoint.ts +++ b/extensions/copilot/src/platform/endpoint/test/node/capiEndpoint.ts @@ -8,7 +8,7 @@ import { IInstantiationService } from '../../../../util/vs/platform/instantiatio import { IAuthenticationService } from '../../../authentication/common/authentication'; import { IChatMLFetcher } from '../../../chat/common/chatMLFetcher'; import { IConfigurationService } from '../../../configuration/common/configurationService'; -import { IEnvService } from '../../../env/common/envService'; +import { ILogService } from '../../../log/common/logService'; import { IFetcherService } from '../../../networking/common/fetcherService'; import { IExperimentationService } from '../../../telemetry/common/nullExperimentationService'; import { ITelemetryService } from '../../../telemetry/common/telemetry'; @@ -17,7 +17,6 @@ import { ICAPIClientService } from '../../common/capiClient'; import { IDomainService } from '../../common/domainService'; import { IChatModelInformation } from '../../common/endpointProvider'; import { ChatEndpoint } from '../../node/chatEndpoint'; -import { ILogService } from '../../../log/common/logService'; export class CAPITestEndpoint extends ChatEndpoint { @@ -27,7 +26,6 @@ export class CAPITestEndpoint extends ChatEndpoint { @IDomainService domainService: IDomainService, @ICAPIClientService capiClientService: ICAPIClientService, @IFetcherService fetcherService: IFetcherService, - @IEnvService envService: IEnvService, @ITelemetryService telemetryService: ITelemetryService, @IAuthenticationService authService: IAuthenticationService, @IChatMLFetcher chatMLFetcher: IChatMLFetcher, @@ -41,7 +39,6 @@ export class CAPITestEndpoint extends ChatEndpoint { domainService, capiClientService, fetcherService, - envService, telemetryService, authService, chatMLFetcher, diff --git a/extensions/copilot/src/platform/endpoint/test/node/customNesEndpoint.ts b/extensions/copilot/src/platform/endpoint/test/node/customNesEndpoint.ts index b3911dbc2b9..7a29aaad401 100644 --- a/extensions/copilot/src/platform/endpoint/test/node/customNesEndpoint.ts +++ b/extensions/copilot/src/platform/endpoint/test/node/customNesEndpoint.ts @@ -9,6 +9,7 @@ import { IAuthenticationService } from '../../../authentication/common/authentic import { IChatMLFetcher } from '../../../chat/common/chatMLFetcher'; import { CHAT_MODEL, IConfigurationService } from '../../../configuration/common/configurationService'; import { IEnvService } from '../../../env/common/envService'; +import { ILogService } from '../../../log/common/logService'; import { IFetcherService } from '../../../networking/common/fetcherService'; import { IEndpointBody } from '../../../networking/common/networking'; import { IExperimentationService } from '../../../telemetry/common/nullExperimentationService'; @@ -18,7 +19,6 @@ import { ICAPIClientService } from '../../common/capiClient'; import { IDomainService } from '../../common/domainService'; import { IChatModelInformation } from '../../common/endpointProvider'; import { ChatEndpoint } from '../../node/chatEndpoint'; -import { ILogService } from '../../../log/common/logService'; export class CustomNesEndpoint extends ChatEndpoint { constructor( @@ -65,7 +65,6 @@ export class CustomNesEndpoint extends ChatEndpoint { domainService, capiClientService, fetcherService, - envService, telemetryService, authService, chatMLFetcher, diff --git a/extensions/copilot/src/platform/endpoint/test/node/openaiCompatibleEndpoint.ts b/extensions/copilot/src/platform/endpoint/test/node/openaiCompatibleEndpoint.ts index bb6b8ff51f7..762aa180dcd 100644 --- a/extensions/copilot/src/platform/endpoint/test/node/openaiCompatibleEndpoint.ts +++ b/extensions/copilot/src/platform/endpoint/test/node/openaiCompatibleEndpoint.ts @@ -119,7 +119,6 @@ export class OpenAICompatibleTestEndpoint extends ChatEndpoint { domainService, capiClientService, fetcherService, - envService, telemetryService, authService, chatMLFetcher, diff --git a/extensions/copilot/src/platform/endpoint/test/node/testEndpointProvider.ts b/extensions/copilot/src/platform/endpoint/test/node/testEndpointProvider.ts index a7b2ab7db01..a3a25e5880b 100644 --- a/extensions/copilot/src/platform/endpoint/test/node/testEndpointProvider.ts +++ b/extensions/copilot/src/platform/endpoint/test/node/testEndpointProvider.ts @@ -21,7 +21,6 @@ import { IRequestLogger } from '../../../requestLogger/node/requestLogger'; import { IExperimentationService } from '../../../telemetry/common/nullExperimentationService'; import { ITelemetryService } from '../../../telemetry/common/telemetry'; import { ICAPIClientService } from '../../common/capiClient'; -import { IDomainService } from '../../common/domainService'; import { ChatEndpointFamily, IChatModelInformation, ICompletionModelInformation, IEndpointProvider } from '../../common/endpointProvider'; import { ModelMetadataFetcher } from '../../node/modelMetadataFetcher'; import { AzureTestEndpoint } from './azureEndpoint'; @@ -68,7 +67,6 @@ export class TestModelMetadataFetcher extends ModelMetadataFetcher { info: CurrentTestRunInfo | undefined, private readonly _skipModelMetadataCache: boolean = false, @IFetcherService _fetcher: IFetcherService, - @IDomainService _domainService: IDomainService, @ICAPIClientService _capiClientService: ICAPIClientService, @IConfigurationService _configService: IConfigurationService, @IExperimentationService _expService: IExperimentationService, @@ -84,7 +82,6 @@ export class TestModelMetadataFetcher extends ModelMetadataFetcher { _isModelLab, _fetcher, _requestLogger, - _domainService, _capiClientService, _configService, _expService, diff --git a/extensions/copilot/src/platform/networking/common/networking.ts b/extensions/copilot/src/platform/networking/common/networking.ts index 688f975750d..92a8d31b9bd 100644 --- a/extensions/copilot/src/platform/networking/common/networking.ts +++ b/extensions/copilot/src/platform/networking/common/networking.ts @@ -13,8 +13,6 @@ import { CancellationError } from '../../../util/vs/base/common/errors'; import { Source } from '../../chat/common/chatMLFetcher'; import type { ChatLocation, ChatResponse } from '../../chat/common/commonTypes'; import { ICAPIClientService } from '../../endpoint/common/capiClient'; -import { IDomainService } from '../../endpoint/common/domainService'; -import { IEnvService } from '../../env/common/envService'; import { ILogService } from '../../log/common/logService'; import { ITelemetryService, TelemetryProperties } from '../../telemetry/common/telemetry'; import { TelemetryData } from '../../telemetry/common/telemetryData'; @@ -246,14 +244,11 @@ export function createCapiRequestBody(options: ICreateEndpointBodyOptions, model function networkRequest( fetcher: IFetcher, - envService: IEnvService, telemetryService: ITelemetryService, - domainService: IDomainService, capiClientService: ICAPIClientService, requestType: 'GET' | 'POST', endpointOrUrl: IEndpoint | string | RequestMetadata, secretKey: string, - hmac: string | undefined, intent: string, requestId: string, body?: IEndpointBody, @@ -339,9 +334,7 @@ export function canRetryOnceNetworkError(reason: any) { export function postRequest( fetcherService: IFetcherService, - envService: IEnvService, telemetryService: ITelemetryService, - domainService: IDomainService, capiClientService: ICAPIClientService, endpointOrUrl: IEndpoint | string | RequestMetadata, secretKey: string, @@ -353,14 +346,11 @@ export function postRequest( cancelToken?: CancellationToken ): Promise { return networkRequest(fetcherService, - envService, telemetryService, - domainService, capiClientService, 'POST', endpointOrUrl, secretKey, - hmac, intent, requestId, body, @@ -371,9 +361,7 @@ export function postRequest( export function getRequest( fetcherService: IFetcher, - envService: IEnvService, telemetryService: ITelemetryService, - domainService: IDomainService, capiClientService: ICAPIClientService, endpointOrUrl: IEndpoint | string | RequestMetadata, secretKey: string, @@ -385,14 +373,11 @@ export function getRequest( cancelToken?: CancellationToken ): Promise { return networkRequest(fetcherService, - envService, telemetryService, - domainService, capiClientService, 'GET', endpointOrUrl, secretKey, - hmac, intent, requestId, body, diff --git a/extensions/copilot/src/platform/networking/test/node/networking.spec.ts b/extensions/copilot/src/platform/networking/test/node/networking.spec.ts index a93522de36f..9fb09d0ba2d 100644 --- a/extensions/copilot/src/platform/networking/test/node/networking.spec.ts +++ b/extensions/copilot/src/platform/networking/test/node/networking.spec.ts @@ -7,8 +7,6 @@ import { RequestType } from '@vscode/copilot-api'; import assert from 'assert'; import { suite, test } from 'vitest'; import { ICAPIClientService } from '../../../endpoint/common/capiClient'; -import { IDomainService } from '../../../endpoint/common/domainService'; -import { IEnvService } from '../../../env/common/envService'; import { ITelemetryService } from '../../../telemetry/common/telemetry'; import { createFakeResponse } from '../../../test/node/fetcher'; import { createPlatformServices } from '../../../test/node/services'; @@ -56,9 +54,7 @@ suite('Networking test Suite', function () { const accessor = testingServiceCollection.createTestingAccessor(); await postRequest( accessor.get(IFetcherService), - accessor.get(IEnvService), accessor.get(ITelemetryService), - accessor.get(IDomainService), accessor.get(ICAPIClientService), { type: RequestType.Models }, '', diff --git a/extensions/copilot/src/platform/openai/node/fetch.ts b/extensions/copilot/src/platform/openai/node/fetch.ts index cf01af4d3be..4170cf4f4ed 100644 --- a/extensions/copilot/src/platform/openai/node/fetch.ts +++ b/extensions/copilot/src/platform/openai/node/fetch.ts @@ -7,6 +7,7 @@ import { ClientHttp2Stream } from 'http2'; import type { CancellationToken } from 'vscode'; import { createRequestHMAC } from '../../../util/common/crypto'; import { generateUuid } from '../../../util/vs/base/common/uuid'; +import { ServicesAccessor } from '../../../util/vs/platform/instantiation/common/instantiation'; import { IAuthenticationService } from '../../authentication/common/authentication'; import { IChatQuotaService } from '../../chat/common/chatQuotaService'; import { ChatLocation } from '../../chat/common/commonTypes'; @@ -96,15 +97,7 @@ export enum ChatFailKind { * or rewrite is necessary to have a more generic fetcher that can be used for both completions and chat models. */ export async function fetchAndStreamChat( - logService: ILogService, - telemetryService: ITelemetryService, - fetcherService: IFetcherService, - envService: IEnvService, - chatQuotaService: IChatQuotaService, - domainService: IDomainService, - capiClientService: ICAPIClientService, - authenticationService: IAuthenticationService, - interactionService: IInteractionService, + accessor: ServicesAccessor, chatEndpointInfo: IChatEndpoint, request: IEndpointBody, baseTelemetryData: TelemetryData, @@ -117,6 +110,15 @@ export async function fetchAndStreamChat( cancel?: CancellationToken | undefined, telemetryProperties?: TelemetryProperties | undefined ): Promise { + const logService = accessor.get(ILogService); + const telemetryService = accessor.get(ITelemetryService); + const fetcherService = accessor.get(IFetcherService); + const envService = accessor.get(IEnvService); + const chatQuotaService = accessor.get(IChatQuotaService); + const domainService = accessor.get(IDomainService); + const capiClientService = accessor.get(ICAPIClientService); + const authenticationService = accessor.get(IAuthenticationService); + const interactionService = accessor.get(IInteractionService); if (cancel?.isCancellationRequested) { return { type: FetchResponseKind.Canceled, reason: 'before fetch request' }; } @@ -179,7 +181,7 @@ export async function fetchAndStreamChat( if (response.status !== 200) { const telemetryData = createTelemetryData(chatEndpointInfo, location, ourRequestId); logService.info('Request ID for failed request: ' + ourRequestId); - return handleError(logService, telemetryService, authenticationService, telemetryData, response, ourRequestId); + return handleError(accessor, telemetryData, response, ourRequestId); } // Extend baseTelemetryData with modelCallId for output messages @@ -220,13 +222,14 @@ function createTelemetryData(chatEndpointInfo: IChatEndpoint, location: ChatLoca } async function handleError( - logService: ILogService, - telemetryService: ITelemetryService, - authenticationService: IAuthenticationService, + accessor: ServicesAccessor, telemetryData: TelemetryData, response: Response, requestId: string, ): Promise { + const logService = accessor.get(ILogService); + const telemetryService = accessor.get(ITelemetryService); + const authenticationService = accessor.get(IAuthenticationService); const modelRequestIdObj = getRequestId(response, undefined); requestId = modelRequestIdObj.headerRequestId || requestId; modelRequestIdObj.headerRequestId = requestId; @@ -501,9 +504,7 @@ async function fetchWithInstrumentation( // Wrap the Promise with success/error callbacks so we can log/measure it return postRequest( fetcherService, - envService, telemetryService, - domainService, capiClientService, chatEndpoint, secretKey, diff --git a/extensions/copilot/src/platform/remoteCodeSearch/common/adoCodeSearchService.ts b/extensions/copilot/src/platform/remoteCodeSearch/common/adoCodeSearchService.ts index 098d33b541f..0952d379062 100644 --- a/extensions/copilot/src/platform/remoteCodeSearch/common/adoCodeSearchService.ts +++ b/extensions/copilot/src/platform/remoteCodeSearch/common/adoCodeSearchService.ts @@ -20,7 +20,6 @@ import { stripChunkTextMetadata } from '../../chunking/common/chunkingStringUtil import { ConfigKey, IConfigurationService } from '../../configuration/common/configurationService'; import { EmbeddingType } from '../../embeddings/common/embeddingsComputer'; import { ICAPIClientService } from '../../endpoint/common/capiClient'; -import { IDomainService } from '../../endpoint/common/domainService'; import { IEnvService } from '../../env/common/envService'; import { AdoRepoId } from '../../git/common/gitService'; import { IIgnoreService } from '../../ignore/common/ignoreService'; @@ -122,7 +121,6 @@ export class AdoCodeSearchService extends Disposable implements IAdoCodeSearchSe constructor( @IAuthenticationService private readonly _authenticationService: IAuthenticationService, @IConfigurationService private readonly _configurationService: IConfigurationService, - @IDomainService private readonly _domainService: IDomainService, @ICAPIClientService private readonly _capiClientService: ICAPIClientService, @IEnvService private readonly _envService: IEnvService, @IExperimentationService private readonly _expService: IExperimentationService, @@ -195,9 +193,7 @@ export class AdoCodeSearchService extends Disposable implements IAdoCodeSearchSe const result = await raceCancellationError( getRequest( this._fetcherService, - this._envService, this._telemetryService, - this._domainService, this._capiClientService, endpoint, authToken, @@ -301,9 +297,7 @@ export class AdoCodeSearchService extends Disposable implements IAdoCodeSearchSe const response = await raceCancellationError( postRequest( this._fetcherService, - this._envService, this._telemetryService, - this._domainService, this._capiClientService, endpoint, authToken, diff --git a/extensions/copilot/src/platform/remoteCodeSearch/common/githubCodeSearchService.ts b/extensions/copilot/src/platform/remoteCodeSearch/common/githubCodeSearchService.ts index 2dc9459c150..14ec42ec317 100644 --- a/extensions/copilot/src/platform/remoteCodeSearch/common/githubCodeSearchService.ts +++ b/extensions/copilot/src/platform/remoteCodeSearch/common/githubCodeSearchService.ts @@ -20,7 +20,6 @@ import { getGithubMetadataHeaders } from '../../chunking/common/chunkingEndpoint import { stripChunkTextMetadata, truncateToMaxUtf8Length } from '../../chunking/common/chunkingStringUtils'; import { EmbeddingType } from '../../embeddings/common/embeddingsComputer'; import { ICAPIClientService } from '../../endpoint/common/capiClient'; -import { IDomainService } from '../../endpoint/common/domainService'; import { IEnvService } from '../../env/common/envService'; import { GithubRepoId, toGithubNwo } from '../../git/common/gitService'; import { IIgnoreService } from '../../ignore/common/ignoreService'; @@ -109,7 +108,6 @@ export class GithubCodeSearchService implements IGithubCodeSearchService { constructor( @IAuthenticationService private readonly _authenticationService: IAuthenticationService, - @IDomainService private readonly _domainService: IDomainService, @ICAPIClientService private readonly _capiClientService: ICAPIClientService, @IEnvService private readonly _envService: IEnvService, @IFetcherService private readonly _fetcherService: IFetcherService, @@ -271,9 +269,7 @@ export class GithubCodeSearchService implements IGithubCodeSearchService { const response = await raceCancellationError( postRequest( this._fetcherService, - this._envService, this._telemetryService, - this._domainService, this._capiClientService, { type: RequestType.EmbeddingsCodeSearch }, authToken, diff --git a/extensions/copilot/src/platform/remoteSearch/node/codeOrDocsSearchClientImpl.ts b/extensions/copilot/src/platform/remoteSearch/node/codeOrDocsSearchClientImpl.ts index f0e0b40a685..30e8d07349a 100644 --- a/extensions/copilot/src/platform/remoteSearch/node/codeOrDocsSearchClientImpl.ts +++ b/extensions/copilot/src/platform/remoteSearch/node/codeOrDocsSearchClientImpl.ts @@ -10,8 +10,6 @@ import { CancellationError, isCancellationError } from '../../../util/vs/base/co import { generateUuid } from '../../../util/vs/base/common/uuid'; import { IAuthenticationService } from '../../authentication/common/authentication'; import { ICAPIClientService } from '../../endpoint/common/capiClient'; -import { IDomainService } from '../../endpoint/common/domainService'; -import { IEnvService } from '../../env/common/envService'; import { LogExecTime } from '../../log/common/logExecTime'; import { ILogService } from '../../log/common/logService'; import { IFetcherService } from '../../networking/common/fetcherService'; @@ -57,12 +55,10 @@ export class DocsSearchClient implements IDocsSearchClient { private readonly slug = 'docs'; constructor( - @IDomainService private readonly _domainService: IDomainService, @ICAPIClientService private readonly _capiClientService: ICAPIClientService, @ITelemetryService private readonly _telemetryService: ITelemetryService, @IAuthenticationService private readonly _authenticationService: IAuthenticationService, @IFetcherService private readonly _fetcherService: IFetcherService, - @IEnvService private readonly _envService: IEnvService, @ILogService private readonly _logService: ILogService, ) { } @@ -198,9 +194,7 @@ export class DocsSearchClient implements IDocsSearchClient { }; const response = await postRequest( this._fetcherService, - this._envService, this._telemetryService, - this._domainService, this._capiClientService, endpointInfo, authToken ?? '', diff --git a/extensions/copilot/src/platform/workspaceChunkSearch/common/githubAvailableEmbeddingTypes.ts b/extensions/copilot/src/platform/workspaceChunkSearch/common/githubAvailableEmbeddingTypes.ts index bc22b240e2f..9ba99a0575d 100644 --- a/extensions/copilot/src/platform/workspaceChunkSearch/common/githubAvailableEmbeddingTypes.ts +++ b/extensions/copilot/src/platform/workspaceChunkSearch/common/githubAvailableEmbeddingTypes.ts @@ -14,7 +14,6 @@ import { getGithubMetadataHeaders } from '../../chunking/common/chunkingEndpoint import { ConfigKey, IConfigurationService } from '../../configuration/common/configurationService'; import { EmbeddingType } from '../../embeddings/common/embeddingsComputer'; import { ICAPIClientService } from '../../endpoint/common/capiClient'; -import { IDomainService } from '../../endpoint/common/domainService'; import { IEnvService } from '../../env/common/envService'; import { ILogService } from '../../log/common/logService'; import { IFetcherService, Response } from '../../networking/common/fetcherService'; @@ -44,7 +43,6 @@ export class GithubAvailableEmbeddingTypesManager { @ILogService private readonly _logService: ILogService, @IAuthenticationService private readonly _authService: IAuthenticationService, @ITelemetryService private readonly _telemetryService: ITelemetryService, - @IDomainService private readonly _domainService: IDomainService, @ICAPIClientService private readonly _capiClientService: ICAPIClientService, @IEnvService private readonly _envService: IEnvService, @IFetcherService private readonly _fetcherService: IFetcherService, @@ -103,9 +101,7 @@ export class GithubAvailableEmbeddingTypesManager { try { response = await getRequest( this._fetcherService, - this._envService, this._telemetryService, - this._domainService, this._capiClientService, { type: RequestType.EmbeddingsModels }, token, diff --git a/extensions/copilot/test/base/cachingEmbeddingsFetcher.ts b/extensions/copilot/test/base/cachingEmbeddingsFetcher.ts index 1b879395a00..f54b13774a3 100644 --- a/extensions/copilot/test/base/cachingEmbeddingsFetcher.ts +++ b/extensions/copilot/test/base/cachingEmbeddingsFetcher.ts @@ -7,7 +7,6 @@ import { IAuthenticationService } from '../../src/platform/authentication/common import { ComputeEmbeddingsOptions, Embedding, EmbeddingType, EmbeddingVector, Embeddings, LEGACY_EMBEDDING_MODEL_ID, getWellKnownEmbeddingTypeInfo } from '../../src/platform/embeddings/common/embeddingsComputer'; import { RemoteEmbeddingsComputer } from '../../src/platform/embeddings/common/remoteEmbeddingsComputer'; import { ICAPIClientService } from '../../src/platform/endpoint/common/capiClient'; -import { IDomainService } from '../../src/platform/endpoint/common/domainService'; import { IEnvService } from '../../src/platform/env/common/envService'; import { ILogService } from '../../src/platform/log/common/logService'; import { IFetcherService } from '../../src/platform/networking/common/fetcherService'; @@ -47,7 +46,6 @@ export class CachingEmbeddingsComputer extends RemoteEmbeddingsComputer { private readonly cache: IEmbeddingsCache, @IAuthenticationService authService: IAuthenticationService, @ICAPIClientService capiClientService: ICAPIClientService, - @IDomainService domainService: IDomainService, @IEnvService envService: IEnvService, @IFetcherService fetcherService: IFetcherService, @ILogService logService: ILogService, @@ -56,7 +54,6 @@ export class CachingEmbeddingsComputer extends RemoteEmbeddingsComputer { super( authService, capiClientService, - domainService, envService, fetcherService, logService,