@vscode/chat-lib 0.2.1-27 → 0.2.1-29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/ghostText/copilotCompletion.d.ts +1 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/ghostText/copilotCompletion.d.ts.map +1 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/ghostText/copilotCompletion.js +0 -4
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/ghostText/copilotCompletion.js.map +1 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/ghostText/ghostText.d.ts +71 -4
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/ghostText/ghostText.d.ts.map +1 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/ghostText/ghostText.js +254 -229
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/ghostText/ghostText.js.map +1 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/ghostText/last.d.ts +2 -4
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/ghostText/last.d.ts.map +1 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/ghostText/last.js +5 -5
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/ghostText/last.js.map +1 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/ghostText/streamedCompletionSplitter.d.ts.map +1 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/ghostText/streamedCompletionSplitter.js +0 -4
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/ghostText/streamedCompletionSplitter.js.map +1 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/ghostText/telemetry.d.ts +2 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/ghostText/telemetry.d.ts.map +1 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/ghostText/telemetry.js +4 -3
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/ghostText/telemetry.js.map +1 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/networking.d.ts +1 -0
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/networking.d.ts.map +1 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/networking.js +1 -0
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/networking.js.map +1 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/openai/fetch.d.ts +25 -7
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/openai/fetch.d.ts.map +1 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/openai/fetch.js +316 -23
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/openai/fetch.js.map +1 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/openai/openai.d.ts +5 -9
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/openai/openai.d.ts.map +1 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/openai/openai.js +0 -3
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/openai/openai.js.map +1 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/openai/stream.d.ts +3 -27
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/openai/stream.d.ts.map +1 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/openai/stream.js +16 -61
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/openai/stream.js.map +1 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/postInsertion.d.ts +1 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/postInsertion.d.ts.map +1 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/postInsertion.js +0 -4
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/postInsertion.js.map +1 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/prompt/completionsPromptFactory/componentsCompletionsPromptFactory.d.ts +2 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/prompt/completionsPromptFactory/componentsCompletionsPromptFactory.d.ts.map +1 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/prompt/completionsPromptFactory/componentsCompletionsPromptFactory.js +12 -7
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/prompt/completionsPromptFactory/componentsCompletionsPromptFactory.js.map +1 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/prompt/components/diagnostics.d.ts +10 -0
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/prompt/components/diagnostics.d.ts.map +1 -0
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/prompt/components/diagnostics.js +92 -0
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/prompt/components/diagnostics.js.map +1 -0
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/prompt/components/splitContextPrompt.d.ts.map +1 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/prompt/components/splitContextPrompt.js +2 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/prompt/components/splitContextPrompt.js.map +1 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/prompt/contextProviders/contextItemSchemas.d.ts +6 -2
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/prompt/contextProviders/contextItemSchemas.d.ts.map +1 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/prompt/contextProviders/contextItemSchemas.js +106 -43
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/prompt/contextProviders/contextItemSchemas.js.map +1 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/prompt/contextProviders/diagnostics.d.ts +5 -0
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/prompt/contextProviders/diagnostics.d.ts.map +1 -0
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/prompt/contextProviders/diagnostics.js +59 -0
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/prompt/contextProviders/diagnostics.js.map +1 -0
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/suggestions/anomalyDetection.d.ts +1 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/suggestions/anomalyDetection.d.ts.map +1 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/suggestions/anomalyDetection.js.map +1 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/telemetry.d.ts +2 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/telemetry.d.ts.map +1 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/lib/src/telemetry.js.map +1 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/types/src/contextProviderApiV1.d.ts +10 -2
- package/dist/src/_internal/extension/completions-core/vscode-node/types/src/contextProviderApiV1.d.ts.map +1 -1
- package/dist/src/_internal/extension/completions-core/vscode-node/types/src/contextProviderApiV1.js +8 -0
- package/dist/src/_internal/extension/completions-core/vscode-node/types/src/contextProviderApiV1.js.map +1 -1
- package/dist/src/_internal/extension/inlineEdits/node/nextEditCache.d.ts +6 -2
- package/dist/src/_internal/extension/inlineEdits/node/nextEditCache.d.ts.map +1 -1
- package/dist/src/_internal/extension/inlineEdits/node/nextEditCache.js +5 -5
- package/dist/src/_internal/extension/inlineEdits/node/nextEditCache.js.map +1 -1
- package/dist/src/_internal/extension/inlineEdits/node/nextEditProvider.d.ts.map +1 -1
- package/dist/src/_internal/extension/inlineEdits/node/nextEditProvider.js +10 -7
- package/dist/src/_internal/extension/inlineEdits/node/nextEditProvider.js.map +1 -1
- package/dist/src/_internal/extension/inlineEdits/node/nextEditResult.d.ts +3 -0
- package/dist/src/_internal/extension/inlineEdits/node/nextEditResult.d.ts.map +1 -1
- package/dist/src/_internal/extension/inlineEdits/node/nextEditResult.js.map +1 -1
- package/dist/src/_internal/extension/prompt/node/chatMLFetcher.d.ts.map +1 -1
- package/dist/src/_internal/extension/prompt/node/chatMLFetcher.js +26 -15
- package/dist/src/_internal/extension/prompt/node/chatMLFetcher.js.map +1 -1
- package/dist/src/_internal/extension/prompt/node/chatMLFetcherTelemetry.d.ts +7 -4
- package/dist/src/_internal/extension/prompt/node/chatMLFetcherTelemetry.d.ts.map +1 -1
- package/dist/src/_internal/extension/prompt/node/chatMLFetcherTelemetry.js +24 -8
- package/dist/src/_internal/extension/prompt/node/chatMLFetcherTelemetry.js.map +1 -1
- package/dist/src/_internal/extension/xtab/common/promptCrafting.d.ts.map +1 -1
- package/dist/src/_internal/extension/xtab/common/promptCrafting.js +11 -6
- package/dist/src/_internal/extension/xtab/common/promptCrafting.js.map +1 -1
- package/dist/src/_internal/extension/xtab/node/xtabCustomDiffPatchResponseHandler.d.ts.map +1 -1
- package/dist/src/_internal/extension/xtab/node/xtabCustomDiffPatchResponseHandler.js +1 -0
- package/dist/src/_internal/extension/xtab/node/xtabCustomDiffPatchResponseHandler.js.map +1 -1
- package/dist/src/_internal/extension/xtab/node/xtabNextCursorPredictor.d.ts.map +1 -1
- package/dist/src/_internal/extension/xtab/node/xtabNextCursorPredictor.js +5 -0
- package/dist/src/_internal/extension/xtab/node/xtabNextCursorPredictor.js.map +1 -1
- package/dist/src/_internal/extension/xtab/node/xtabProvider.d.ts +10 -4
- package/dist/src/_internal/extension/xtab/node/xtabProvider.d.ts.map +1 -1
- package/dist/src/_internal/extension/xtab/node/xtabProvider.js +25 -9
- package/dist/src/_internal/extension/xtab/node/xtabProvider.js.map +1 -1
- package/dist/src/_internal/platform/authentication/common/authentication.d.ts +2 -1
- package/dist/src/_internal/platform/authentication/common/authentication.d.ts.map +1 -1
- package/dist/src/_internal/platform/authentication/common/authentication.js +7 -2
- package/dist/src/_internal/platform/authentication/common/authentication.js.map +1 -1
- package/dist/src/_internal/platform/authentication/common/staticGitHubAuthenticationService.js +1 -1
- package/dist/src/_internal/platform/authentication/common/staticGitHubAuthenticationService.js.map +1 -1
- package/dist/src/_internal/platform/chat/common/commonTypes.js +1 -1
- package/dist/src/_internal/platform/chat/common/commonTypes.js.map +1 -1
- package/dist/src/_internal/platform/completions-core/common/openai/copilotAnnotations.d.ts +27 -0
- package/dist/src/_internal/platform/completions-core/common/openai/copilotAnnotations.d.ts.map +1 -0
- package/dist/src/_internal/platform/completions-core/common/openai/copilotAnnotations.js +35 -0
- package/dist/src/_internal/platform/completions-core/common/openai/copilotAnnotations.js.map +1 -0
- package/dist/src/_internal/platform/configuration/common/configurationService.d.ts +37 -26
- package/dist/src/_internal/platform/configuration/common/configurationService.d.ts.map +1 -1
- package/dist/src/_internal/platform/configuration/common/configurationService.js +17 -5
- package/dist/src/_internal/platform/configuration/common/configurationService.js.map +1 -1
- package/dist/src/_internal/platform/endpoint/node/chatEndpoint.d.ts.map +1 -1
- package/dist/src/_internal/platform/endpoint/node/chatEndpoint.js +6 -2
- package/dist/src/_internal/platform/endpoint/node/chatEndpoint.js.map +1 -1
- package/dist/src/_internal/platform/endpoint/node/messagesApi.d.ts +11 -2
- package/dist/src/_internal/platform/endpoint/node/messagesApi.d.ts.map +1 -1
- package/dist/src/_internal/platform/endpoint/node/messagesApi.js +106 -9
- package/dist/src/_internal/platform/endpoint/node/messagesApi.js.map +1 -1
- package/dist/src/_internal/platform/endpoint/node/responsesApi.d.ts.map +1 -1
- package/dist/src/_internal/platform/endpoint/node/responsesApi.js +3 -4
- package/dist/src/_internal/platform/endpoint/node/responsesApi.js.map +1 -1
- package/dist/src/_internal/platform/inlineCompletions/common/api.d.ts +5 -1
- package/dist/src/_internal/platform/inlineCompletions/common/api.d.ts.map +1 -1
- package/dist/src/_internal/platform/inlineEdits/common/dataTypes/languageContext.d.ts +7 -1
- package/dist/src/_internal/platform/inlineEdits/common/dataTypes/languageContext.d.ts.map +1 -1
- package/dist/src/_internal/platform/inlineEdits/common/dataTypes/languageContext.js +18 -2
- package/dist/src/_internal/platform/inlineEdits/common/dataTypes/languageContext.js.map +1 -1
- package/dist/src/_internal/platform/inlineEdits/common/dataTypes/xtabPromptOptions.d.ts +1 -0
- package/dist/src/_internal/platform/inlineEdits/common/dataTypes/xtabPromptOptions.d.ts.map +1 -1
- package/dist/src/_internal/platform/inlineEdits/common/dataTypes/xtabPromptOptions.js +1 -0
- package/dist/src/_internal/platform/inlineEdits/common/dataTypes/xtabPromptOptions.js.map +1 -1
- package/dist/src/_internal/platform/inlineEdits/common/inlineEditLogContext.d.ts +1 -0
- package/dist/src/_internal/platform/inlineEdits/common/inlineEditLogContext.d.ts.map +1 -1
- package/dist/src/_internal/platform/inlineEdits/common/inlineEditLogContext.js +120 -0
- package/dist/src/_internal/platform/inlineEdits/common/inlineEditLogContext.js.map +1 -1
- package/dist/src/_internal/platform/inlineEdits/common/statelessNextEditProvider.d.ts +1 -0
- package/dist/src/_internal/platform/inlineEdits/common/statelessNextEditProvider.d.ts.map +1 -1
- package/dist/src/_internal/platform/inlineEdits/common/statelessNextEditProvider.js.map +1 -1
- package/dist/src/_internal/platform/languageServer/common/languageContextService.d.ts +27 -2
- package/dist/src/_internal/platform/languageServer/common/languageContextService.d.ts.map +1 -1
- package/dist/src/_internal/platform/languageServer/common/languageContextService.js +1 -0
- package/dist/src/_internal/platform/languageServer/common/languageContextService.js.map +1 -1
- package/dist/src/_internal/platform/log/common/logService.d.ts +12 -0
- package/dist/src/_internal/platform/log/common/logService.d.ts.map +1 -1
- package/dist/src/_internal/platform/log/common/logService.js +39 -0
- package/dist/src/_internal/platform/log/common/logService.js.map +1 -1
- package/dist/src/_internal/platform/nesFetch/common/completionsAPI.d.ts +74 -0
- package/dist/src/_internal/platform/nesFetch/common/completionsAPI.d.ts.map +1 -0
- package/dist/src/_internal/platform/nesFetch/common/completionsAPI.js +23 -0
- package/dist/src/_internal/platform/nesFetch/common/completionsAPI.js.map +1 -0
- package/dist/src/_internal/platform/nesFetch/common/completionsFetchService.d.ts +72 -0
- package/dist/src/_internal/platform/nesFetch/common/completionsFetchService.d.ts.map +1 -0
- package/dist/src/_internal/platform/nesFetch/common/completionsFetchService.js +44 -0
- package/dist/src/_internal/platform/nesFetch/common/completionsFetchService.js.map +1 -0
- package/dist/src/_internal/platform/nesFetch/common/responseStream.d.ts +35 -0
- package/dist/src/_internal/platform/nesFetch/common/responseStream.d.ts.map +1 -0
- package/dist/src/_internal/platform/nesFetch/common/responseStream.js +162 -0
- package/dist/src/_internal/platform/nesFetch/common/responseStream.js.map +1 -0
- package/dist/src/_internal/platform/nesFetch/node/completionsFetchServiceImpl.d.ts +29 -0
- package/dist/src/_internal/platform/nesFetch/node/completionsFetchServiceImpl.d.ts.map +1 -0
- package/dist/src/_internal/platform/nesFetch/node/completionsFetchServiceImpl.js +171 -0
- package/dist/src/_internal/platform/nesFetch/node/completionsFetchServiceImpl.js.map +1 -0
- package/dist/src/_internal/platform/nesFetch/node/streamTransformer.d.ts +10 -0
- package/dist/src/_internal/platform/nesFetch/node/streamTransformer.d.ts.map +1 -0
- package/dist/src/_internal/platform/nesFetch/node/streamTransformer.js +86 -0
- package/dist/src/_internal/platform/nesFetch/node/streamTransformer.js.map +1 -0
- package/dist/src/_internal/platform/networking/common/anthropic.d.ts +77 -8
- package/dist/src/_internal/platform/networking/common/anthropic.d.ts.map +1 -1
- package/dist/src/_internal/platform/networking/common/anthropic.js +106 -14
- package/dist/src/_internal/platform/networking/common/anthropic.js.map +1 -1
- package/dist/src/_internal/platform/networking/common/fetch.d.ts +8 -2
- package/dist/src/_internal/platform/networking/common/fetch.d.ts.map +1 -1
- package/dist/src/_internal/platform/networking/common/fetch.js +5 -5
- package/dist/src/_internal/platform/networking/common/fetch.js.map +1 -1
- package/dist/src/_internal/platform/networking/common/fetcherService.d.ts +35 -6
- package/dist/src/_internal/platform/networking/common/fetcherService.d.ts.map +1 -1
- package/dist/src/_internal/platform/networking/common/fetcherService.js +96 -11
- package/dist/src/_internal/platform/networking/common/fetcherService.js.map +1 -1
- package/dist/src/_internal/platform/networking/node/stream.d.ts.map +1 -1
- package/dist/src/_internal/platform/networking/node/stream.js +14 -15
- package/dist/src/_internal/platform/networking/node/stream.js.map +1 -1
- package/dist/src/_internal/platform/requestLogger/node/nullRequestLogger.d.ts +1 -0
- package/dist/src/_internal/platform/requestLogger/node/nullRequestLogger.d.ts.map +1 -1
- package/dist/src/_internal/platform/requestLogger/node/nullRequestLogger.js +2 -0
- package/dist/src/_internal/platform/requestLogger/node/nullRequestLogger.js.map +1 -1
- package/dist/src/_internal/platform/requestLogger/node/requestLogger.d.ts +2 -0
- package/dist/src/_internal/platform/requestLogger/node/requestLogger.d.ts.map +1 -1
- package/dist/src/_internal/platform/requestLogger/node/requestLogger.js.map +1 -1
- package/dist/src/_internal/util/common/test/shims/chatTypes.d.ts +7 -0
- package/dist/src/_internal/util/common/test/shims/chatTypes.d.ts.map +1 -1
- package/dist/src/_internal/util/common/test/shims/chatTypes.js +10 -1
- package/dist/src/_internal/util/common/test/shims/chatTypes.js.map +1 -1
- package/dist/src/_internal/util/common/test/shims/vscodeTypesShim.d.ts.map +1 -1
- package/dist/src/_internal/util/common/test/shims/vscodeTypesShim.js +3 -2
- package/dist/src/_internal/util/common/test/shims/vscodeTypesShim.js.map +1 -1
- package/dist/src/_internal/util/common/tracing.d.ts +13 -0
- package/dist/src/_internal/util/common/tracing.d.ts.map +1 -1
- package/dist/src/_internal/util/common/tracing.js +7 -0
- package/dist/src/_internal/util/common/tracing.js.map +1 -1
- package/dist/src/_internal/vscodeTypes.d.ts +1 -0
- package/dist/src/_internal/vscodeTypes.d.ts.map +1 -1
- package/dist/src/_internal/vscodeTypes.js +2 -1
- package/dist/src/_internal/vscodeTypes.js.map +1 -1
- package/dist/src/main.d.ts.map +1 -1
- package/dist/src/main.js +3 -0
- package/dist/src/main.js.map +1 -1
- package/dist/src/package.json +346 -206
- package/package.json +1 -1
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
+
}) : function(o, v) {
|
|
20
|
+
o["default"] = v;
|
|
21
|
+
});
|
|
22
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
23
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
24
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
25
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
26
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
27
|
+
};
|
|
28
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
29
|
+
var ownKeys = function(o) {
|
|
30
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
31
|
+
var ar = [];
|
|
32
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
33
|
+
return ar;
|
|
34
|
+
};
|
|
35
|
+
return ownKeys(o);
|
|
36
|
+
};
|
|
37
|
+
return function (mod) {
|
|
38
|
+
if (mod && mod.__esModule) return mod;
|
|
39
|
+
var result = {};
|
|
40
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
41
|
+
__setModuleDefault(result, mod);
|
|
42
|
+
return result;
|
|
43
|
+
};
|
|
44
|
+
})();
|
|
45
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
46
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
47
|
+
};
|
|
48
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
49
|
+
exports.CompletionsFetchService = void 0;
|
|
50
|
+
const errors = __importStar(require("../../../util/common/errors"));
|
|
51
|
+
const result_1 = require("../../../util/common/result");
|
|
52
|
+
const async_1 = require("../../../util/vs/base/common/async");
|
|
53
|
+
const authentication_1 = require("../../authentication/common/authentication");
|
|
54
|
+
const fetch_1 = require("../../networking/common/fetch");
|
|
55
|
+
const fetcherService_1 = require("../../networking/common/fetcherService");
|
|
56
|
+
const completionsFetchService_1 = require("../common/completionsFetchService");
|
|
57
|
+
const responseStream_1 = require("../common/responseStream");
|
|
58
|
+
const streamTransformer_1 = require("./streamTransformer");
|
|
59
|
+
let CompletionsFetchService = class CompletionsFetchService {
|
|
60
|
+
constructor(authService, fetcherService) {
|
|
61
|
+
this.authService = authService;
|
|
62
|
+
this.fetcherService = fetcherService;
|
|
63
|
+
}
|
|
64
|
+
disconnectAll() {
|
|
65
|
+
return this.fetcherService.disconnectAll();
|
|
66
|
+
}
|
|
67
|
+
async fetch(url, secretKey, params, requestId, ct, headerOverrides) {
|
|
68
|
+
if (ct.isCancellationRequested) {
|
|
69
|
+
return result_1.Result.error(new completionsFetchService_1.Completions.RequestCancelled());
|
|
70
|
+
}
|
|
71
|
+
const options = {
|
|
72
|
+
requestId,
|
|
73
|
+
headers: this.getHeaders(requestId, secretKey, headerOverrides),
|
|
74
|
+
body: JSON.stringify({
|
|
75
|
+
...params,
|
|
76
|
+
stream: true,
|
|
77
|
+
})
|
|
78
|
+
};
|
|
79
|
+
const fetchResponse = await this._fetchFromUrl(url, options, ct);
|
|
80
|
+
if (fetchResponse.isError()) {
|
|
81
|
+
return fetchResponse;
|
|
82
|
+
}
|
|
83
|
+
if (fetchResponse.val.status === 200) {
|
|
84
|
+
const jsonlStream = (0, streamTransformer_1.streamToLines)(fetchResponse.val.body);
|
|
85
|
+
const completionsStream = (0, streamTransformer_1.jsonlStreamToCompletions)(jsonlStream);
|
|
86
|
+
const response = new responseStream_1.ResponseStream(fetchResponse.val.response, completionsStream, fetchResponse.val.requestId, fetchResponse.val.headers);
|
|
87
|
+
return result_1.Result.ok(response);
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
const error = new completionsFetchService_1.Completions.UnsuccessfulResponse(fetchResponse.val.status, fetchResponse.val.statusText, fetchResponse.val.headers, () => fetchResponse.val.body.toPromise().then(arr => arr.join('')).catch(() => ''));
|
|
91
|
+
return result_1.Result.error(error);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
async _fetchFromUrl(url, options, ct) {
|
|
95
|
+
const fetchAbortCtl = this.fetcherService.makeAbortController();
|
|
96
|
+
const onCancellationDisposable = ct.onCancellationRequested(() => {
|
|
97
|
+
fetchAbortCtl.abort();
|
|
98
|
+
});
|
|
99
|
+
try {
|
|
100
|
+
const request = {
|
|
101
|
+
headers: options.headers,
|
|
102
|
+
body: options.body,
|
|
103
|
+
signal: fetchAbortCtl.signal,
|
|
104
|
+
method: 'POST',
|
|
105
|
+
};
|
|
106
|
+
const response = await this.fetcherService.fetch(url, request);
|
|
107
|
+
if (response.status === 200 && this.authService.copilotToken?.isFreeUser && this.authService.copilotToken?.isChatQuotaExceeded) {
|
|
108
|
+
this.authService.resetCopilotToken();
|
|
109
|
+
}
|
|
110
|
+
if (response.status !== 200) {
|
|
111
|
+
if (response.status === 402) {
|
|
112
|
+
// When we receive a 402, we have exceed the free tier quota
|
|
113
|
+
// This is stored on the token so let's refresh it
|
|
114
|
+
if (!this.authService.copilotToken?.isCompletionsQuotaExceeded) {
|
|
115
|
+
this.authService.resetCopilotToken(response.status);
|
|
116
|
+
await this.authService.getCopilotToken();
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return result_1.Result.error(new completionsFetchService_1.Completions.UnsuccessfulResponse(response.status, response.statusText, response.headers, () => response.text().catch(() => '')));
|
|
120
|
+
}
|
|
121
|
+
const body = response.body.pipeThrough(new TextDecoderStream());
|
|
122
|
+
const responseStream = new async_1.AsyncIterableObject(async (emitter) => {
|
|
123
|
+
try {
|
|
124
|
+
for await (const str of body) {
|
|
125
|
+
emitter.emitOne(str);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
catch (err) {
|
|
129
|
+
const error = errors.fromUnknown(err);
|
|
130
|
+
emitter.reject(error);
|
|
131
|
+
}
|
|
132
|
+
finally {
|
|
133
|
+
onCancellationDisposable.dispose();
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
return result_1.Result.ok({
|
|
137
|
+
status: response.status,
|
|
138
|
+
statusText: response.statusText,
|
|
139
|
+
headers: response.headers,
|
|
140
|
+
body: responseStream,
|
|
141
|
+
requestId: (0, fetch_1.getRequestId)(response.headers),
|
|
142
|
+
response,
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
catch (reason) {
|
|
146
|
+
onCancellationDisposable.dispose();
|
|
147
|
+
if (reason instanceof Error && reason.message === 'This operation was aborted') {
|
|
148
|
+
return result_1.Result.error(new completionsFetchService_1.Completions.RequestCancelled());
|
|
149
|
+
}
|
|
150
|
+
const error = errors.fromUnknown(reason);
|
|
151
|
+
return result_1.Result.error(new completionsFetchService_1.Completions.Unexpected(error));
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
getHeaders(requestId, secretKey, headerOverrides = {}) {
|
|
155
|
+
const headers = {
|
|
156
|
+
'Content-Type': 'application/json',
|
|
157
|
+
'x-policy-id': 'nil',
|
|
158
|
+
Authorization: 'Bearer ' + secretKey,
|
|
159
|
+
'X-Request-Id': requestId,
|
|
160
|
+
'X-GitHub-Api-Version': '2025-04-01',
|
|
161
|
+
...headerOverrides,
|
|
162
|
+
};
|
|
163
|
+
return headers;
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
exports.CompletionsFetchService = CompletionsFetchService;
|
|
167
|
+
exports.CompletionsFetchService = CompletionsFetchService = __decorate([
|
|
168
|
+
__param(0, authentication_1.IAuthenticationService),
|
|
169
|
+
__param(1, fetcherService_1.IFetcherService)
|
|
170
|
+
], CompletionsFetchService);
|
|
171
|
+
//# sourceMappingURL=completionsFetchServiceImpl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"completionsFetchServiceImpl.js","sourceRoot":"","sources":["../../../../../../src/_internal/platform/nesFetch/node/completionsFetchServiceImpl.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEhG,oEAAsD;AACtD,wDAAqD;AACrD,8DAAyE;AAEzE,+EAAoF;AACpF,yDAAwE;AACxE,2EAA2G;AAC3G,+EAA0F;AAC1F,6DAA0D;AAC1D,2DAA8E;AAavE,IAAM,uBAAuB,GAA7B,MAAM,uBAAuB;IAGnC,YACiC,WAAmC,EAC1C,cAA+B;QADxB,gBAAW,GAAX,WAAW,CAAwB;QAC1C,mBAAc,GAAd,cAAc,CAAiB;IAEzD,CAAC;IAEM,aAAa;QACnB,OAAO,IAAI,CAAC,cAAc,CAAC,aAAa,EAAE,CAAC;IAC5C,CAAC;IAEM,KAAK,CAAC,KAAK,CACjB,GAAW,EACX,SAAiB,EACjB,MAA2B,EAC3B,SAAiB,EACjB,EAAqB,EACrB,eAAwC;QAGxC,IAAI,EAAE,CAAC,uBAAuB,EAAE,CAAC;YAChC,OAAO,eAAM,CAAC,KAAK,CAAC,IAAI,qCAAW,CAAC,gBAAgB,E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O,EAAE,CAAC;YAEnC,IAAI,MAAM,YAAY,KAAK,IAAI,MAAM,CAAC,OAAO,KAAK,4BAA4B,EAAE,CAAC;gBAChF,OAAO,eAAM,CAAC,KAAK,CAAC,IAAI,qCAAW,CAAC,gBAAgB,EAAE,CAAC,CAAC;YACzD,CAAC;YAED,MAAM,KAAK,GAAG,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;YACzC,OAAO,eAAM,CAAC,KAAK,CAAC,IAAI,qCAAW,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;QACxD,CAAC;IACF,CAAC;IAEO,UAAU,CACjB,SAAiB,EACjB,SAAiB,EACjB,kBAA0C,EAAE;QAE5C,MAAM,OAAO,GAA2B;YACvC,cAAc,EAAE,kBAAkB;YAClC,aAAa,EAAE,KAAK;YACpB,aAAa,EAAE,SAAS,GAAG,SAAS;YACpC,cAAc,EAAE,SAAS;YACzB,sBAAsB,EAAE,YAAY;YACpC,GAAG,eAAe;SAClB,CAAC;QAEF,OAAO,OAAO,CAAC;IAChB,CAAC;CACD,CAAA;AAvJY,0DAAuB;kCAAvB,uBAAuB;IAIjC,WAAA,uCAAsB,CAAA;IACtB,WAAA,gCAAe,CAAA;GALL,uBAAuB,CAuJnC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AsyncIterableObject } from '../../../util/vs/base/common/async';
|
|
2
|
+
import { Completion } from '../common/completionsAPI';
|
|
3
|
+
/**
|
|
4
|
+
* Transforms a stream of strings into a stream of lines.
|
|
5
|
+
*
|
|
6
|
+
* Listener should handle the errors coming from the input stream.
|
|
7
|
+
*/
|
|
8
|
+
export declare function streamToLines(stream: AsyncIterableObject<string>): AsyncIterableObject<string>;
|
|
9
|
+
export declare function jsonlStreamToCompletions(jsonlStream: AsyncIterableObject<string>): AsyncIterableObject<Completion>;
|
|
10
|
+
//# sourceMappingURL=streamTransformer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streamTransformer.d.ts","sourceRoot":"","sources":["../../../../../../src/_internal/platform/nesFetch/node/streamTransformer.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEtD;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,mBAAmB,CAAC,MAAM,CAAC,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAyB9F;AAED,wBAAgB,wBAAwB,CAAC,WAAW,EAAE,mBAAmB,CAAC,MAAM,CAAC,GAAG,mBAAmB,CAAC,UAAU,CAAC,CA2BlH"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.streamToLines = streamToLines;
|
|
8
|
+
exports.jsonlStreamToCompletions = jsonlStreamToCompletions;
|
|
9
|
+
const async_1 = require("../../../util/vs/base/common/async");
|
|
10
|
+
/**
|
|
11
|
+
* Transforms a stream of strings into a stream of lines.
|
|
12
|
+
*
|
|
13
|
+
* Listener should handle the errors coming from the input stream.
|
|
14
|
+
*/
|
|
15
|
+
function streamToLines(stream) {
|
|
16
|
+
return new async_1.AsyncIterableObject(async (emitter) => {
|
|
17
|
+
let buffer = '';
|
|
18
|
+
for await (const str of stream) {
|
|
19
|
+
buffer += str;
|
|
20
|
+
do {
|
|
21
|
+
const newlineIndex = buffer.indexOf('\n');
|
|
22
|
+
if (newlineIndex === -1) {
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
// take the first line
|
|
26
|
+
const line = buffer.substring(0, newlineIndex);
|
|
27
|
+
buffer = buffer.substring(newlineIndex + 1);
|
|
28
|
+
emitter.emitOne(line);
|
|
29
|
+
} while (true);
|
|
30
|
+
}
|
|
31
|
+
if (buffer.length > 0) {
|
|
32
|
+
// last line which doesn't end with \n
|
|
33
|
+
emitter.emitOne(buffer);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
function jsonlStreamToCompletions(jsonlStream) {
|
|
38
|
+
return new async_1.AsyncIterableObject(async (emitter) => {
|
|
39
|
+
for await (const line of jsonlStream) {
|
|
40
|
+
if (line.trim() === 'data: [DONE]') {
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
if (line.startsWith('data: ')) {
|
|
44
|
+
try {
|
|
45
|
+
const message = JSON.parse(line.substring('data: '.length));
|
|
46
|
+
if (message.error) {
|
|
47
|
+
emitter.reject(new Error(message.error.message));
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
emitter.emitOne(message);
|
|
51
|
+
}
|
|
52
|
+
catch (err) {
|
|
53
|
+
emitter.reject(err);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
// function replaceBytes(s: string): string {
|
|
61
|
+
// if (!s.startsWith('bytes:')) {
|
|
62
|
+
// return s;
|
|
63
|
+
// }
|
|
64
|
+
// const bytes: number[] = [];
|
|
65
|
+
// let i = 'bytes:'.length;
|
|
66
|
+
// const textEncoder = new TextEncoder();
|
|
67
|
+
// while (i < s.length) {
|
|
68
|
+
// if (s.slice(i, i + 3) === '\\\\x') {
|
|
69
|
+
// bytes.push(parseInt(s.slice(i + 3, i + 5), 16));
|
|
70
|
+
// i += 5;
|
|
71
|
+
// } else if (s.slice(i, i + 2) === '\\x') {
|
|
72
|
+
// bytes.push(parseInt(s.slice(i + 2, i + 4), 16));
|
|
73
|
+
// i += 4;
|
|
74
|
+
// } else {
|
|
75
|
+
// const encoded = textEncoder.encode(s.slice(i, i + 1));
|
|
76
|
+
// for (const b of encoded) {
|
|
77
|
+
// bytes.push(b);
|
|
78
|
+
// }
|
|
79
|
+
// i += 1;
|
|
80
|
+
// }
|
|
81
|
+
// }
|
|
82
|
+
// return new TextDecoder('utf8', { fatal: false }).decode(
|
|
83
|
+
// new Uint8Array(bytes)
|
|
84
|
+
// );
|
|
85
|
+
// }
|
|
86
|
+
//# sourceMappingURL=streamTransformer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streamTransformer.js","sourceRoot":"","sources":["../../../../../../src/_internal/platform/nesFetch/node/streamTransformer.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;AAUhG,sCAyBC;AAED,4DA2BC;AA9DD,8DAAyE;AAGzE;;;;GAIG;AACH,SAAgB,aAAa,CAAC,MAAmC;IAChE,OAAO,IAAI,2BAAmB,CAAS,KAAK,EAAE,OAAO,EAAE,EAAE;QACxD,IAAI,MAAM,GAAG,EAAE,CAAC;QAEhB,IAAI,KAAK,EAAE,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;YAChC,MAAM,IAAI,GAAG,CAAC;YACd,GAAG,CAAC;gBACH,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;gBAC1C,IAAI,YAAY,KAAK,CAAC,CAAC,EAAE,CAAC;oBACzB,MAAM;gBACP,CAAC;gBAED,sBAAsB;gBACtB,MAAM,IAAI,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;gBAC/C,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,YAAY,GAAG,CAAC,CAAC,CAAC;gBAE5C,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YACvB,CAAC,QAAQ,IAAI,EAAE;QAChB,CAAC;QAED,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACvB,sCAAsC;YACtC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACzB,CAAC;IACF,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
|
|
1
1
|
import { IConfigurationService } from '../../configuration/common/configurationService';
|
|
2
2
|
import { IExperimentationService } from '../../telemetry/common/nullExperimentationService';
|
|
3
|
+
import { IChatEndpoint } from './networking';
|
|
3
4
|
/**
|
|
4
5
|
* Types for Anthropic Messages API
|
|
5
6
|
* Based on https://platform.claude.com/docs/en/api/messages
|
|
7
|
+
*
|
|
8
|
+
* This interface supports both regular tools and server tools (web search, tool search):
|
|
9
|
+
* - Regular tools: require name, description, and input_schema
|
|
10
|
+
* - Tool search tools: require only type and name
|
|
6
11
|
*/
|
|
7
12
|
export interface AnthropicMessagesTool {
|
|
8
13
|
name: string;
|
|
14
|
+
type?: string;
|
|
9
15
|
description?: string;
|
|
10
|
-
input_schema
|
|
16
|
+
input_schema?: {
|
|
11
17
|
type: 'object';
|
|
12
18
|
properties?: Record<string, unknown>;
|
|
13
19
|
required?: string[];
|
|
14
20
|
};
|
|
21
|
+
defer_loading?: boolean;
|
|
15
22
|
}
|
|
23
|
+
export interface ToolReference {
|
|
24
|
+
type: 'tool_reference';
|
|
25
|
+
tool_name: string;
|
|
26
|
+
}
|
|
27
|
+
export interface ToolSearchToolSearchResult {
|
|
28
|
+
type: 'tool_search_tool_search_result';
|
|
29
|
+
tool_references: ToolReference[];
|
|
30
|
+
}
|
|
31
|
+
export interface ToolSearchToolResultError {
|
|
32
|
+
type: 'tool_search_tool_result_error';
|
|
33
|
+
error_code: 'too_many_requests' | 'invalid_pattern' | 'pattern_too_long' | 'unavailable';
|
|
34
|
+
}
|
|
35
|
+
export interface ServerToolUse {
|
|
36
|
+
type: 'server_tool_use';
|
|
37
|
+
id: string;
|
|
38
|
+
name: string;
|
|
39
|
+
input: {
|
|
40
|
+
query: string;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
export interface ToolSearchToolResult {
|
|
44
|
+
type: 'tool_search_tool_result';
|
|
45
|
+
tool_use_id: string;
|
|
46
|
+
content: ToolSearchToolSearchResult | ToolSearchToolResultError;
|
|
47
|
+
}
|
|
48
|
+
export interface ToolSearchUsage {
|
|
49
|
+
tool_search_requests: number;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Tools that should not use deferred loading when tool search is enabled.
|
|
53
|
+
* These are frequently used tools that benefit from being immediately available.
|
|
54
|
+
*
|
|
55
|
+
* TODO: @bhavyaus Replace these hardcoded strings with constants from ToolName enum
|
|
56
|
+
*/
|
|
57
|
+
export declare const nonDeferredToolNames: Set<string>;
|
|
16
58
|
/**
|
|
17
59
|
* Context management types for Anthropic Messages API
|
|
18
60
|
* Based on https://platform.claude.com/docs/en/build-with-claude/context-editing
|
|
@@ -61,13 +103,40 @@ export interface ContextManagementResponse {
|
|
|
61
103
|
applied_edits: AppliedContextEdit[];
|
|
62
104
|
}
|
|
63
105
|
/**
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
106
|
+
* Context editing is supported by:
|
|
107
|
+
* - Claude Haiku 4.5 (claude-haiku-4-5-* or claude-haiku-4.5-*)
|
|
108
|
+
* - Claude Sonnet 4.5 (claude-sonnet-4-5-* or claude-sonnet-4.5-*)
|
|
109
|
+
* - Claude Sonnet 4 (claude-sonnet-4-*)
|
|
110
|
+
* - Claude Opus 4.5 (claude-opus-4-5-* or claude-opus-4.5-*)
|
|
111
|
+
* - Claude Opus 4.1 (claude-opus-4-1-* or claude-opus-4.1-*)
|
|
112
|
+
* - Claude Opus 4 (claude-opus-4-*)
|
|
113
|
+
* @param modelId The model ID to check
|
|
114
|
+
* @returns true if the model supports context editing
|
|
115
|
+
*/
|
|
116
|
+
export declare function modelSupportsContextEditing(modelId: string): boolean;
|
|
117
|
+
/**
|
|
118
|
+
* Tool search is only supported by:
|
|
119
|
+
* - Claude Sonnet 4.5 (claude-sonnet-4-5-* or claude-sonnet-4.5-*)
|
|
120
|
+
* - Claude Opus 4.5 (claude-opus-4-5-* or claude-opus-4.5-*)
|
|
121
|
+
* @param modelId The model ID to check
|
|
122
|
+
* @returns true if the model supports tool search
|
|
123
|
+
*/
|
|
124
|
+
export declare function modelSupportsToolSearch(modelId: string): boolean;
|
|
125
|
+
/**
|
|
126
|
+
* Memory is supported by:
|
|
127
|
+
* - Claude Haiku 4.5 (claude-haiku-4-5-* or claude-haiku-4.5-*)
|
|
128
|
+
* - Claude Sonnet 4.5 (claude-sonnet-4-5-* or claude-sonnet-4.5-*)
|
|
129
|
+
* - Claude Sonnet 4 (claude-sonnet-4-*)
|
|
130
|
+
* - Claude Opus 4.5 (claude-opus-4-5-* or claude-opus-4.5-*)
|
|
131
|
+
* - Claude Opus 4.1 (claude-opus-4-1-* or claude-opus-4.1-*)
|
|
132
|
+
* - Claude Opus 4 (claude-opus-4-*)
|
|
133
|
+
* @param modelId The model ID to check
|
|
134
|
+
* @returns true if the model supports memory
|
|
69
135
|
*/
|
|
70
|
-
export declare function
|
|
136
|
+
export declare function modelSupportsMemory(modelId: string): boolean;
|
|
137
|
+
export declare function isAnthropicMemoryEnabled(endpoint: IChatEndpoint | string, configurationService: IConfigurationService, experimentationService: IExperimentationService): boolean;
|
|
138
|
+
export declare function isAnthropicToolSearchEnabled(endpoint: IChatEndpoint | string, configurationService: IConfigurationService, experimentationService: IExperimentationService): boolean;
|
|
139
|
+
export declare function isAnthropicContextEditingEnabled(endpoint: IChatEndpoint | string, configurationService: IConfigurationService, experimentationService: IExperimentationService): boolean;
|
|
71
140
|
export interface ContextEditingConfig {
|
|
72
141
|
triggerType: 'input_tokens' | 'tool_uses';
|
|
73
142
|
triggerValue: number;
|
|
@@ -94,5 +163,5 @@ export declare function buildContextManagement(config: ContextEditingConfig, has
|
|
|
94
163
|
* @param modelMaxInputTokens The maximum input tokens supported by the model
|
|
95
164
|
* @returns The context_management object to include in the request, or undefined if disabled
|
|
96
165
|
*/
|
|
97
|
-
export declare function getContextManagementFromConfig(
|
|
166
|
+
export declare function getContextManagementFromConfig(experimentationService: IExperimentationService, thinkingBudget: number | undefined, modelMaxInputTokens: number): ContextManagement | undefined;
|
|
98
167
|
//# sourceMappingURL=anthropic.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anthropic.d.ts","sourceRoot":"","sources":["../../../../../../src/_internal/platform/networking/common/anthropic.ts"],"names":[],"mappings":"AAKA,OAAO,EAAa,qBAAqB,EAAE,MAAM,iDAAiD,CAAC;AACnG,OAAO,EAAE,uBAAuB,EAAE,MAAM,mDAAmD,CAAC;
|
|
1
|
+
{"version":3,"file":"anthropic.d.ts","sourceRoot":"","sources":["../../../../../../src/_internal/platform/networking/common/anthropic.ts"],"names":[],"mappings":"AAKA,OAAO,EAAa,qBAAqB,EAAE,MAAM,iDAAiD,CAAC;AACnG,OAAO,EAAE,uBAAuB,EAAE,MAAM,mDAAmD,CAAC;AAC5F,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C;;;;;;;GAOG;AACH,MAAM,WAAW,qBAAqB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE;QACd,IAAI,EAAE,QAAQ,CAAC;QACf,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACrC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;KACpB,CAAC;IACF,aAAa,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,aAAa;IAC7B,IAAI,EAAE,gBAAgB,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,0BAA0B;IAC1C,IAAI,EAAE,gCAAgC,CAAC;IACvC,eAAe,EAAE,aAAa,EAAE,CAAC;CACjC;AAED,MAAM,WAAW,yBAAyB;IACzC,IAAI,EAAE,+BAA+B,CAAC;IACtC,UAAU,EAAE,mBAAmB,GAAG,iBAAiB,GAAG,kBAAkB,GAAG,aAAa,CAAC;CACzF;A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,SAAS,EAAE,MAAM,CAAC;IAClB,kBAAkB,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,WAAW,EAAE,OAAO,CAAC;IACrB,iBAAiB,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACrC,MAAM,EAAE,oBAAoB,EAC5B,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,cAAc,EAAE,MAAM,GACpB,iBAAiB,GAAG,SAAS,CA6B/B;AAED;;;;;;;;GAQG;AACH,wBAAgB,8BAA8B,CAC7C,sBAAsB,EAAE,uBAAuB,EAC/C,cAAc,EAAE,MAAM,GAAG,SAAS,EAClC,mBAAmB,EAAE,MAAM,GACzB,iBAAiB,GAAG,SAAS,CAa/B"}
|
|
@@ -4,21 +4,117 @@
|
|
|
4
4
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5
5
|
*--------------------------------------------------------------------------------------------*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.nonDeferredToolNames = void 0;
|
|
8
|
+
exports.modelSupportsContextEditing = modelSupportsContextEditing;
|
|
9
|
+
exports.modelSupportsToolSearch = modelSupportsToolSearch;
|
|
10
|
+
exports.modelSupportsMemory = modelSupportsMemory;
|
|
11
|
+
exports.isAnthropicMemoryEnabled = isAnthropicMemoryEnabled;
|
|
12
|
+
exports.isAnthropicToolSearchEnabled = isAnthropicToolSearchEnabled;
|
|
7
13
|
exports.isAnthropicContextEditingEnabled = isAnthropicContextEditingEnabled;
|
|
8
14
|
exports.buildContextManagement = buildContextManagement;
|
|
9
15
|
exports.getContextManagementFromConfig = getContextManagementFromConfig;
|
|
10
16
|
const configurationService_1 = require("../../configuration/common/configurationService");
|
|
11
17
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* @
|
|
16
|
-
* @returns true if Anthropic context editing is enabled
|
|
18
|
+
* Tools that should not use deferred loading when tool search is enabled.
|
|
19
|
+
* These are frequently used tools that benefit from being immediately available.
|
|
20
|
+
*
|
|
21
|
+
* TODO: @bhavyaus Replace these hardcoded strings with constants from ToolName enum
|
|
17
22
|
*/
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
23
|
+
exports.nonDeferredToolNames = new Set([
|
|
24
|
+
// Read/navigate
|
|
25
|
+
'read_file',
|
|
26
|
+
'list_dir',
|
|
27
|
+
// Search
|
|
28
|
+
'grep_search',
|
|
29
|
+
'semantic_search',
|
|
30
|
+
'file_search',
|
|
31
|
+
// Edit
|
|
32
|
+
'replace_string_in_file',
|
|
33
|
+
'multi_replace_string_in_file',
|
|
34
|
+
'insert_edit_into_file',
|
|
35
|
+
'apply_patch',
|
|
36
|
+
'create_file',
|
|
37
|
+
// Terminal
|
|
38
|
+
'run_in_terminal',
|
|
39
|
+
'get_terminal_output',
|
|
40
|
+
// Other high-usage tools
|
|
41
|
+
'get_errors',
|
|
42
|
+
'manage_todo_list',
|
|
43
|
+
]);
|
|
44
|
+
/**
|
|
45
|
+
* Context editing is supported by:
|
|
46
|
+
* - Claude Haiku 4.5 (claude-haiku-4-5-* or claude-haiku-4.5-*)
|
|
47
|
+
* - Claude Sonnet 4.5 (claude-sonnet-4-5-* or claude-sonnet-4.5-*)
|
|
48
|
+
* - Claude Sonnet 4 (claude-sonnet-4-*)
|
|
49
|
+
* - Claude Opus 4.5 (claude-opus-4-5-* or claude-opus-4.5-*)
|
|
50
|
+
* - Claude Opus 4.1 (claude-opus-4-1-* or claude-opus-4.1-*)
|
|
51
|
+
* - Claude Opus 4 (claude-opus-4-*)
|
|
52
|
+
* @param modelId The model ID to check
|
|
53
|
+
* @returns true if the model supports context editing
|
|
54
|
+
*/
|
|
55
|
+
function modelSupportsContextEditing(modelId) {
|
|
56
|
+
// Normalize: lowercase and replace dots with dashes so "4.5" matches "4-5"
|
|
57
|
+
const normalized = modelId.toLowerCase().replace(/\./g, '-');
|
|
58
|
+
return normalized.startsWith('claude-haiku-4-5') ||
|
|
59
|
+
normalized.startsWith('claude-sonnet-4-5') ||
|
|
60
|
+
normalized.startsWith('claude-sonnet-4') ||
|
|
61
|
+
normalized.startsWith('claude-opus-4-5') ||
|
|
62
|
+
normalized.startsWith('claude-opus-4-1') ||
|
|
63
|
+
normalized.startsWith('claude-opus-4');
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Tool search is only supported by:
|
|
67
|
+
* - Claude Sonnet 4.5 (claude-sonnet-4-5-* or claude-sonnet-4.5-*)
|
|
68
|
+
* - Claude Opus 4.5 (claude-opus-4-5-* or claude-opus-4.5-*)
|
|
69
|
+
* @param modelId The model ID to check
|
|
70
|
+
* @returns true if the model supports tool search
|
|
71
|
+
*/
|
|
72
|
+
function modelSupportsToolSearch(modelId) {
|
|
73
|
+
// Normalize: lowercase and replace dots with dashes so "4.5" matches "4-5"
|
|
74
|
+
const normalized = modelId.toLowerCase().replace(/\./g, '-');
|
|
75
|
+
return normalized.startsWith('claude-sonnet-4-5') ||
|
|
76
|
+
normalized.startsWith('claude-opus-4-5');
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Memory is supported by:
|
|
80
|
+
* - Claude Haiku 4.5 (claude-haiku-4-5-* or claude-haiku-4.5-*)
|
|
81
|
+
* - Claude Sonnet 4.5 (claude-sonnet-4-5-* or claude-sonnet-4.5-*)
|
|
82
|
+
* - Claude Sonnet 4 (claude-sonnet-4-*)
|
|
83
|
+
* - Claude Opus 4.5 (claude-opus-4-5-* or claude-opus-4.5-*)
|
|
84
|
+
* - Claude Opus 4.1 (claude-opus-4-1-* or claude-opus-4.1-*)
|
|
85
|
+
* - Claude Opus 4 (claude-opus-4-*)
|
|
86
|
+
* @param modelId The model ID to check
|
|
87
|
+
* @returns true if the model supports memory
|
|
88
|
+
*/
|
|
89
|
+
function modelSupportsMemory(modelId) {
|
|
90
|
+
const normalized = modelId.toLowerCase().replace(/\./g, '-');
|
|
91
|
+
return normalized.startsWith('claude-haiku-4-5') ||
|
|
92
|
+
normalized.startsWith('claude-sonnet-4-5') ||
|
|
93
|
+
normalized.startsWith('claude-sonnet-4') ||
|
|
94
|
+
normalized.startsWith('claude-opus-4-5') ||
|
|
95
|
+
normalized.startsWith('claude-opus-4-1') ||
|
|
96
|
+
normalized.startsWith('claude-opus-4');
|
|
97
|
+
}
|
|
98
|
+
function isAnthropicMemoryEnabled(endpoint, configurationService, experimentationService) {
|
|
99
|
+
const effectiveModelId = typeof endpoint === 'string' ? endpoint : endpoint.model;
|
|
100
|
+
if (!modelSupportsMemory(effectiveModelId)) {
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
return configurationService.getExperimentBasedConfig(configurationService_1.ConfigKey.MemoryToolEnabled, experimentationService);
|
|
104
|
+
}
|
|
105
|
+
function isAnthropicToolSearchEnabled(endpoint, configurationService, experimentationService) {
|
|
106
|
+
const effectiveModelId = typeof endpoint === 'string' ? endpoint : endpoint.model;
|
|
107
|
+
if (!modelSupportsToolSearch(effectiveModelId)) {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
return configurationService.getExperimentBasedConfig(configurationService_1.ConfigKey.AnthropicToolSearchEnabled, experimentationService);
|
|
111
|
+
}
|
|
112
|
+
function isAnthropicContextEditingEnabled(endpoint, configurationService, experimentationService) {
|
|
113
|
+
const effectiveModelId = typeof endpoint === 'string' ? endpoint : endpoint.model;
|
|
114
|
+
if (!modelSupportsContextEditing(effectiveModelId)) {
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
return configurationService.getExperimentBasedConfig(configurationService_1.ConfigKey.AnthropicContextEditingEnabled, experimentationService);
|
|
22
118
|
}
|
|
23
119
|
/**
|
|
24
120
|
* Builds the context_management configuration object for the Messages API request.
|
|
@@ -61,11 +157,7 @@ function buildContextManagement(config, hasThinking, modelMaxTokens) {
|
|
|
61
157
|
* @param modelMaxInputTokens The maximum input tokens supported by the model
|
|
62
158
|
* @returns The context_management object to include in the request, or undefined if disabled
|
|
63
159
|
*/
|
|
64
|
-
function getContextManagementFromConfig(
|
|
65
|
-
const contextEditingEnabled = configurationService.getConfig(configurationService_1.ConfigKey.AnthropicContextEditingEnabled);
|
|
66
|
-
if (!contextEditingEnabled) {
|
|
67
|
-
return undefined;
|
|
68
|
-
}
|
|
160
|
+
function getContextManagementFromConfig(experimentationService, thinkingBudget, modelMaxInputTokens) {
|
|
69
161
|
const contextEditingConfig = {
|
|
70
162
|
triggerType: (experimentationService.getTreatmentVariable('copilotchat.anthropic.contextEditing.toolResult.triggerType') ?? 'input_tokens'),
|
|
71
163
|
triggerValue: experimentationService.getTreatmentVariable('copilotchat.anthropic.contextEditing.toolResult.triggerValue') ?? 75000,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anthropic.js","sourceRoot":"","sources":["../../../../../../src/_internal/platform/networking/common/anthropic.ts"],"names":[],"mappings":";AAAA;;;gGAGgG
|
|
1
|
+
{"version":3,"file":"anthropic.js","sourceRoot":"","sources":["../../../../../../src/_internal/platform/networking/common/anthropic.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAoJhG,kEASC;AASD,0DAKC;AAaD,kDAQC;AAGD,4DAYC;AAED,oEAYC;AAED,4EAWC;AAmBD,wDAiCC;AAWD,wEAiBC;AAxTD,0FAAmG;AA0DnG;;;;;GAKG;AACU,QAAA,oBAAoB,GAAG,IAAI,GAAG,CAAC;IAC3C,gBAAgB;IAChB,WAAW;IACX,UAAU;IACV,SAAS;IACT,aAAa;IACb,iBAAiB;IACjB,aAAa;IACb,OAAO;IACP,wBAAwB;IACxB,8BAA8B;IAC9B,uBAAuB;IACvB,aAAa;IACb,aAAa;IACb,WAAW;IACX,iBAAiB;IACjB,qBAAqB;IACrB,yBAAyB;IACzB,YAAY;IACZ,kBAAkB;CAClB,CAAC,CAAC;AAmDH;;;;;;;;;;GAUG;AACH,SAAgB,2BAA2B,CAAC,OAAe;IAC1D,2E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mBAA2B;IAG3B,MAAM,oBAAoB,GAAyB;QAClD,WAAW,EAAE,CAAC,sBAAsB,CAAC,oBAAoB,CAAS,6DAA6D,CAAC,IAAI,cAAc,CAAiC;QACnL,YAAY,EAAE,sBAAsB,CAAC,oBAAoB,CAAS,8DAA8D,CAAC,IAAI,KAAK;QAC1I,SAAS,EAAE,sBAAsB,CAAC,oBAAoB,CAAS,2DAA2D,CAAC,IAAI,CAAC;QAChI,kBAAkB,EAAE,sBAAsB,CAAC,oBAAoB,CAAS,oEAAoE,CAAC,IAAI,IAAI;QACrJ,YAAY,EAAE,EAAE;QAChB,WAAW,EAAE,sBAAsB,CAAC,oBAAoB,CAAU,6DAA6D,CAAC,IAAI,IAAI;QACxI,iBAAiB,EAAE,sBAAsB,CAAC,oBAAoB,CAAS,yDAAyD,CAAC,IAAI,CAAC;KACtI,CAAC;IAEF,OAAO,sBAAsB,CAAC,oBAAoB,EAAE,cAAc,EAAE,mBAAmB,CAAC,CAAC;AAC1F,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EncryptedThinkingDelta, ThinkingData, ThinkingDelta } from '../../thinking/common/thinking';
|
|
2
2
|
import { AnthropicMessagesTool, ContextManagementResponse } from './anthropic';
|
|
3
|
-
import {
|
|
3
|
+
import { IHeaders } from './fetcherService';
|
|
4
4
|
import { ChoiceLogProbs, FilterReason } from './openai';
|
|
5
5
|
export interface RequestId {
|
|
6
6
|
headerRequestId: string;
|
|
@@ -10,7 +10,7 @@ export interface RequestId {
|
|
|
10
10
|
serverExperiments: string;
|
|
11
11
|
deploymentId: string;
|
|
12
12
|
}
|
|
13
|
-
export declare function getRequestId(
|
|
13
|
+
export declare function getRequestId(headers: IHeaders, json?: any): RequestId;
|
|
14
14
|
export interface ICodeVulnerabilityAnnotation {
|
|
15
15
|
details: {
|
|
16
16
|
type: string;
|
|
@@ -41,6 +41,10 @@ export interface ICopilotToolCall {
|
|
|
41
41
|
arguments: string;
|
|
42
42
|
id: string;
|
|
43
43
|
}
|
|
44
|
+
export interface IServerToolCall extends ICopilotToolCall {
|
|
45
|
+
/** Indicates this is a server-side tool call (e.g., tool_search, websearch) - not validated/executed by client */
|
|
46
|
+
isServer: true;
|
|
47
|
+
}
|
|
44
48
|
export interface ICopilotToolCallStreamUpdate {
|
|
45
49
|
name: string;
|
|
46
50
|
arguments: string;
|
|
@@ -93,6 +97,8 @@ export interface IResponseDelta {
|
|
|
93
97
|
statefulMarker?: string;
|
|
94
98
|
/** Context management information from Anthropic Messages API */
|
|
95
99
|
contextManagement?: ContextManagementResponse;
|
|
100
|
+
/** Server-side tool calls (e.g., tool_search) - reported for logging but not validated/executed */
|
|
101
|
+
serverToolCalls?: IServerToolCall[];
|
|
96
102
|
}
|
|
97
103
|
export declare const enum ResponsePartKind {
|
|
98
104
|
ContentDelta = 0,
|