@aws/lsp-codewhisperer 0.0.81 → 0.0.83
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/CHANGELOG.md +43 -0
- package/out/language-server/agenticChat/agenticChatController.js +123 -28
- package/out/language-server/agenticChat/agenticChatController.js.map +1 -1
- package/out/language-server/agenticChat/constants/constants.d.ts +7 -0
- package/out/language-server/agenticChat/constants/constants.js +13 -1
- package/out/language-server/agenticChat/constants/constants.js.map +1 -1
- package/out/language-server/agenticChat/context/additionalContextProvider.d.ts +1 -1
- package/out/language-server/agenticChat/context/additionalContextProvider.js +50 -3
- package/out/language-server/agenticChat/context/additionalContextProvider.js.map +1 -1
- package/out/language-server/agenticChat/context/memorybank/memoryBankController.d.ts +104 -0
- package/out/language-server/agenticChat/context/memorybank/memoryBankController.js +681 -0
- package/out/language-server/agenticChat/context/memorybank/memoryBankController.js.map +1 -0
- package/out/language-server/agenticChat/context/memorybank/memoryBankPrompts.d.ts +14 -0
- package/out/language-server/agenticChat/context/memorybank/memoryBankPrompts.js +156 -0
- package/out/language-server/agenticChat/context/memorybank/memoryBankPrompts.js.map +1 -0
- package/out/language-server/agenticChat/tools/chatDb/chatDb.d.ts +3 -25
- package/out/language-server/agenticChat/tools/chatDb/chatDb.js +12 -107
- package/out/language-server/agenticChat/tools/chatDb/chatDb.js.map +1 -1
- package/out/language-server/agenticChat/tools/chatDb/util.js +1 -2
- package/out/language-server/agenticChat/tools/chatDb/util.js.map +1 -1
- package/out/language-server/agenticChat/tools/fsRead.d.ts +3 -1
- package/out/language-server/agenticChat/tools/fsRead.js +12 -7
- package/out/language-server/agenticChat/tools/fsRead.js.map +1 -1
- package/out/language-server/agenticChat/tools/qCodeAnalysis/codeReview.js +32 -16
- package/out/language-server/agenticChat/tools/qCodeAnalysis/codeReview.js.map +1 -1
- package/out/language-server/agenticChat/tools/qCodeAnalysis/codeReviewConstants.js +1 -1
- package/out/language-server/agenticChat/tools/qCodeAnalysis/codeReviewConstants.js.map +1 -1
- package/out/language-server/agenticChat/tools/qCodeAnalysis/codeReviewTypes.d.ts +8 -0
- package/out/language-server/chat/chatSessionService.d.ts +1 -1
- package/out/language-server/chat/chatSessionService.js +1 -1
- package/out/language-server/chat/chatSessionService.js.map +1 -1
- package/out/language-server/chat/telemetry/chatTelemetryController.d.ts +2 -2
- package/out/language-server/chat/telemetry/chatTelemetryController.js +3 -2
- package/out/language-server/chat/telemetry/chatTelemetryController.js.map +1 -1
- package/out/language-server/inline-completion/codeWhispererServer.js +13 -11
- package/out/language-server/inline-completion/codeWhispererServer.js.map +1 -1
- package/out/language-server/inline-completion/contants/constants.js.map +1 -0
- package/out/language-server/inline-completion/editCompletionHandler.d.ts +1 -1
- package/out/language-server/inline-completion/editCompletionHandler.js +8 -5
- package/out/language-server/inline-completion/editCompletionHandler.js.map +1 -1
- package/out/language-server/inline-completion/session/sessionManager.d.ts +7 -1
- package/out/language-server/inline-completion/session/sessionManager.js +20 -4
- package/out/language-server/inline-completion/session/sessionManager.js.map +1 -1
- package/out/language-server/inline-completion/{telemetry.d.ts → telemetry/telemetry.d.ts} +2 -2
- package/out/language-server/inline-completion/{telemetry.js → telemetry/telemetry.js} +2 -2
- package/out/language-server/inline-completion/telemetry/telemetry.js.map +1 -0
- package/out/language-server/inline-completion/{codeDiffTracker.d.ts → tracker/codeDiffTracker.d.ts} +2 -2
- package/out/language-server/inline-completion/{codeDiffTracker.js → tracker/codeDiffTracker.js} +1 -1
- package/out/language-server/inline-completion/tracker/codeDiffTracker.js.map +1 -0
- package/out/language-server/inline-completion/tracker/codeEditTracker.js +1 -1
- package/out/language-server/inline-completion/tracker/codeEditTracker.js.map +1 -1
- package/out/language-server/inline-completion/{codePercentage.d.ts → tracker/codePercentageTracker.d.ts} +1 -1
- package/out/language-server/inline-completion/{codePercentage.js → tracker/codePercentageTracker.js} +1 -1
- package/out/language-server/inline-completion/tracker/codePercentageTracker.js.map +1 -0
- package/out/language-server/inline-completion/{diffUtils.d.ts → utils/diffUtils.d.ts} +1 -1
- package/out/language-server/inline-completion/{diffUtils.js → utils/diffUtils.js} +1 -1
- package/out/language-server/inline-completion/utils/diffUtils.js.map +1 -0
- package/out/language-server/inline-completion/{mergeRightUtils.d.ts → utils/mergeRightUtils.d.ts} +3 -11
- package/out/language-server/inline-completion/utils/mergeRightUtils.js +95 -0
- package/out/language-server/inline-completion/utils/mergeRightUtils.js.map +1 -0
- package/out/language-server/netTransform/artifactManager.d.ts +2 -2
- package/out/language-server/netTransform/artifactManager.js +6 -10
- package/out/language-server/netTransform/artifactManager.js.map +1 -1
- package/out/shared/amazonQServiceManager/AmazonQIAMServiceManager.d.ts +1 -1
- package/out/shared/amazonQServiceManager/AmazonQIAMServiceManager.js +8 -2
- package/out/shared/amazonQServiceManager/AmazonQIAMServiceManager.js.map +1 -1
- package/out/shared/amazonQServiceManager/AmazonQTokenServiceManager.js +3 -0
- package/out/shared/amazonQServiceManager/AmazonQTokenServiceManager.js.map +1 -1
- package/out/shared/amazonQServiceManager/BaseAmazonQServiceManager.js +6 -0
- package/out/shared/amazonQServiceManager/BaseAmazonQServiceManager.js.map +1 -1
- package/out/shared/codeWhispererService.d.ts +2 -2
- package/out/shared/codeWhispererService.js +37 -6
- package/out/shared/codeWhispererService.js.map +1 -1
- package/out/shared/streamingClientService.d.ts +1 -0
- package/out/shared/streamingClientService.js +20 -3
- package/out/shared/streamingClientService.js.map +1 -1
- package/out/shared/supplementalContextUtil/supplementalContextUtil.js +4 -4
- package/out/shared/supplementalContextUtil/supplementalContextUtil.js.map +1 -1
- package/out/shared/telemetry/telemetryService.d.ts +1 -0
- package/out/shared/telemetry/telemetryService.js +10 -8
- package/out/shared/telemetry/telemetryService.js.map +1 -1
- package/out/shared/testUtils.d.ts +0 -3
- package/out/shared/testUtils.js +2 -21
- package/out/shared/testUtils.js.map +1 -1
- package/out/shared/utils.d.ts +1 -1
- package/out/shared/utils.js +5 -1
- package/out/shared/utils.js.map +1 -1
- package/package.json +3 -4
- package/out/language-server/inline-completion/codeDiffTracker.js.map +0 -1
- package/out/language-server/inline-completion/codePercentage.js.map +0 -1
- package/out/language-server/inline-completion/constants.js.map +0 -1
- package/out/language-server/inline-completion/diffUtils.js.map +0 -1
- package/out/language-server/inline-completion/mergeRightUtils.js +0 -114
- package/out/language-server/inline-completion/mergeRightUtils.js.map +0 -1
- package/out/language-server/inline-completion/telemetry.js.map +0 -1
- /package/out/language-server/inline-completion/{constants.d.ts → contants/constants.d.ts} +0 -0
- /package/out/language-server/inline-completion/{constants.js → contants/constants.js} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,48 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.83](https://github.com/aws/language-servers/compare/lsp-codewhisperer/v0.0.82...lsp-codewhisperer/v0.0.83) (2025-10-01)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* **amazonq:** escaping user input to mitigate xss issue ([#2360](https://github.com/aws/language-servers/issues/2360)) ([45b86be](https://github.com/aws/language-servers/commit/45b86bef1a93cf9ced6fbf0c222cf5410de04c81))
|
|
9
|
+
* **amazonq:** fix to add opt-out header to streaming client ([#2365](https://github.com/aws/language-servers/issues/2365)) ([692e77b](https://github.com/aws/language-servers/commit/692e77bc99770ac7d676928e95e3dc43bb91e7f0))
|
|
10
|
+
* **amazonq:** handle IAM credentials expiration field to be aws sdk versions compatible and add refresh logic to codewhisperer IAM client ([#2349](https://github.com/aws/language-servers/issues/2349)) ([5eb3768](https://github.com/aws/language-servers/commit/5eb3768bf020d61d0ade767d62e13839048146e4))
|
|
11
|
+
* **amazonq:** send full finding details to plugin, partial to agent ([#2356](https://github.com/aws/language-servers/issues/2356)) ([961e6ca](https://github.com/aws/language-servers/commit/961e6ca11b122481685f9f65b3da14c6a2497cc4))
|
|
12
|
+
* improve history management ([#2312](https://github.com/aws/language-servers/issues/2312)) ([#2357](https://github.com/aws/language-servers/issues/2357)) ([e7aa2a6](https://github.com/aws/language-servers/commit/e7aa2a6545bcb1a8238abfde69a05432be0b6615))
|
|
13
|
+
* optimize memory bank token usage and add new tab support ([#2366](https://github.com/aws/language-servers/issues/2366)) ([3057d56](https://github.com/aws/language-servers/commit/3057d56e4a3047d1715d6e3560e9f934d1de469c))
|
|
14
|
+
* private package mapping during artifact generation ([#2348](https://github.com/aws/language-servers/issues/2348)) ([d56bfa1](https://github.com/aws/language-servers/commit/d56bfa191954fac8068e2bf390c2d0b88ef8b168))
|
|
15
|
+
* trim new line when emitting error message ([#2359](https://github.com/aws/language-servers/issues/2359)) ([d8733a7](https://github.com/aws/language-servers/commit/d8733a75487f74815302b838802eccbf3ffec55e))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Reverts
|
|
19
|
+
|
|
20
|
+
* fix to add opt-out header to streaming client ([#2365](https://github.com/aws/language-servers/issues/2365)) ([#2370](https://github.com/aws/language-servers/issues/2370)) ([b29478f](https://github.com/aws/language-servers/commit/b29478fa1ecc58e331ff330ff79f46b0d8c38d9e))
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### Dependencies
|
|
24
|
+
|
|
25
|
+
* The following workspace dependencies were updated
|
|
26
|
+
* dependencies
|
|
27
|
+
* @aws/lsp-core bumped from ^0.0.15 to ^0.0.16
|
|
28
|
+
|
|
29
|
+
## [0.0.82](https://github.com/aws/language-servers/compare/lsp-codewhisperer/v0.0.81...lsp-codewhisperer/v0.0.82) (2025-09-24)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
### Features
|
|
33
|
+
|
|
34
|
+
* memory bank support ([#2314](https://github.com/aws/language-servers/issues/2314)) ([0e215fc](https://github.com/aws/language-servers/commit/0e215fc0e475b4c40a8237492371716982d4d532))
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
### Bug Fixes
|
|
38
|
+
|
|
39
|
+
* **amazonq:** fix to emit event for same region profile switch ([#2320](https://github.com/aws/language-servers/issues/2320)) ([aa1a482](https://github.com/aws/language-servers/commit/aa1a4827871a1cfa9fcd76f7ba420107a5d44b01))
|
|
40
|
+
* **amazonq:** reduce number of findings to 30 as a quick fix ([#2318](https://github.com/aws/language-servers/issues/2318)) ([b31cf67](https://github.com/aws/language-servers/commit/b31cf67ddc68a2ca2e0a4ebd9ee94d0545afc656))
|
|
41
|
+
* **amazonq:** removing a bracket from full review message ([#2317](https://github.com/aws/language-servers/issues/2317)) ([6d321ac](https://github.com/aws/language-servers/commit/6d321ac6f318c27b01f9f97eee45a62798a60cf5))
|
|
42
|
+
* emit error code on failed user messages ([#2322](https://github.com/aws/language-servers/issues/2322)) ([a949ac0](https://github.com/aws/language-servers/commit/a949ac0a9d7a4dbce5fb7c8480952cee0a674b55))
|
|
43
|
+
* inline latency telemetry should account for preprocess time ([#2323](https://github.com/aws/language-servers/issues/2323)) ([68c6d14](https://github.com/aws/language-servers/commit/68c6d1465a3325612052740496cc1e6e50f56b9a))
|
|
44
|
+
* userTriggerDecision STE suggestionType validation error ([#2313](https://github.com/aws/language-servers/issues/2313)) ([8f30ac0](https://github.com/aws/language-servers/commit/8f30ac0ec5f4f7b7c343f5e889aec64a282897ea))
|
|
45
|
+
|
|
3
46
|
## [0.0.81](https://github.com/aws/language-servers/compare/lsp-codewhisperer/v0.0.80...lsp-codewhisperer/v0.0.81) (2025-09-19)
|
|
4
47
|
|
|
5
48
|
|
|
@@ -66,8 +66,8 @@ const activeUserTracker_1 = require("../../shared/activeUserTracker");
|
|
|
66
66
|
const displayFindings_1 = require("./tools/qCodeAnalysis/displayFindings");
|
|
67
67
|
const constants_3 = require("../../shared/constants");
|
|
68
68
|
const IdleWorkspaceManager_1 = require("../workspaceContext/IdleWorkspaceManager");
|
|
69
|
-
const escapeHTML = require("escape-html");
|
|
70
69
|
const semanticSearch_1 = require("./tools/workspaceContext/semanticSearch");
|
|
70
|
+
const memoryBankController_1 = require("./context/memorybank/memoryBankController");
|
|
71
71
|
class AgenticChatController {
|
|
72
72
|
#features;
|
|
73
73
|
#chatSessionManagementService;
|
|
@@ -80,6 +80,7 @@ class AgenticChatController {
|
|
|
80
80
|
#chatHistoryDb;
|
|
81
81
|
#additionalContextProvider;
|
|
82
82
|
#contextCommandsProvider;
|
|
83
|
+
#memoryBankController;
|
|
83
84
|
#stoppedToolUses = new Set();
|
|
84
85
|
#userWrittenCodeTracker;
|
|
85
86
|
#toolUseStartTimes = {};
|
|
@@ -154,6 +155,7 @@ class AgenticChatController {
|
|
|
154
155
|
this.#mcpEventHandler = new mcpEventHandler_1.McpEventHandler(features, telemetryService);
|
|
155
156
|
this.#origin = (0, utils_2.getOriginFromClientInfo)((0, utils_2.getClientName)(this.#features.lsp.getClientInitializeParams()));
|
|
156
157
|
this.#activeUserTracker = activeUserTracker_1.ActiveUserTracker.getInstance(this.#features);
|
|
158
|
+
this.#memoryBankController = memoryBankController_1.MemoryBankController.getInstance(features);
|
|
157
159
|
}
|
|
158
160
|
async onExecuteCommand(params, _token) {
|
|
159
161
|
this.#log(`onExecuteCommand: ${params.command}`);
|
|
@@ -562,17 +564,94 @@ class AgenticChatController {
|
|
|
562
564
|
}
|
|
563
565
|
async onChatPrompt(params, token) {
|
|
564
566
|
// Phase 1: Initial Setup - This happens only once
|
|
565
|
-
params.prompt.prompt = (0, utils_2.sanitizeInput)(params.prompt.prompt || '');
|
|
567
|
+
params.prompt.prompt = (0, utils_2.sanitizeInput)(params.prompt.prompt || '', true);
|
|
566
568
|
IdleWorkspaceManager_1.IdleWorkspaceManager.recordActivityTimestamp();
|
|
567
|
-
const maybeDefaultResponse = !params.prompt.command && (0, utils_1.getDefaultChatResponse)(params.prompt.prompt);
|
|
568
|
-
if (maybeDefaultResponse) {
|
|
569
|
-
return maybeDefaultResponse;
|
|
570
|
-
}
|
|
571
569
|
const sessionResult = this.#chatSessionManagementService.getSession(params.tabId);
|
|
572
570
|
const { data: session, success } = sessionResult;
|
|
573
571
|
if (!success) {
|
|
574
572
|
return new server_interface_1.ResponseError(protocol_1.ErrorCodes.InternalError, sessionResult.error);
|
|
575
573
|
}
|
|
574
|
+
// Memory Bank Creation Flow - Delegate to MemoryBankController
|
|
575
|
+
if (this.#memoryBankController.isMemoryBankCreationRequest(params.prompt.prompt)) {
|
|
576
|
+
this.#features.logging.info(`Memory Bank creation request detected for tabId: ${params.tabId}`);
|
|
577
|
+
session.isMemoryBankGeneration = true;
|
|
578
|
+
// Store original prompt to prevent data loss on failure
|
|
579
|
+
const originalPrompt = params.prompt.prompt;
|
|
580
|
+
try {
|
|
581
|
+
const workspaceFolders = lsp_core_1.workspaceUtils.getWorkspaceFolderPaths(this.#features.workspace);
|
|
582
|
+
const workspaceUri = workspaceFolders.length > 0 ? workspaceFolders[0] : '';
|
|
583
|
+
if (!workspaceUri) {
|
|
584
|
+
throw new Error('No workspace folder found for Memory Bank creation');
|
|
585
|
+
}
|
|
586
|
+
// Check if memory bank already exists to provide appropriate user feedback
|
|
587
|
+
const memoryBankExists = await this.#memoryBankController.memoryBankExists(workspaceUri);
|
|
588
|
+
const actionType = memoryBankExists ? 'Regenerating' : 'Generating';
|
|
589
|
+
this.#features.logging.info(`${actionType} Memory Bank for workspace: ${workspaceUri}`);
|
|
590
|
+
const resultStream = this.#getChatResultStream(params.partialResultToken);
|
|
591
|
+
await resultStream.writeResultBlock({
|
|
592
|
+
body: `Preparing to analyze your project...`,
|
|
593
|
+
type: 'answer',
|
|
594
|
+
messageId: crypto.randomUUID(),
|
|
595
|
+
});
|
|
596
|
+
const comprehensivePrompt = await this.#memoryBankController.prepareComprehensiveMemoryBankPrompt(workspaceUri, async (prompt) => {
|
|
597
|
+
// Direct LLM call for ranking - no agentic loop
|
|
598
|
+
try {
|
|
599
|
+
if (!this.#serviceManager) {
|
|
600
|
+
throw new Error('amazonQServiceManager is not initialized');
|
|
601
|
+
}
|
|
602
|
+
const client = this.#serviceManager.getStreamingClient();
|
|
603
|
+
const requestInput = {
|
|
604
|
+
conversationState: {
|
|
605
|
+
chatTriggerType: codewhisperer_streaming_1.ChatTriggerType.MANUAL,
|
|
606
|
+
currentMessage: {
|
|
607
|
+
userInputMessage: {
|
|
608
|
+
content: prompt,
|
|
609
|
+
},
|
|
610
|
+
},
|
|
611
|
+
},
|
|
612
|
+
};
|
|
613
|
+
const response = await client.sendMessage(requestInput);
|
|
614
|
+
let responseContent = '';
|
|
615
|
+
const maxResponseSize = 50000; // 50KB limit
|
|
616
|
+
if (response.sendMessageResponse) {
|
|
617
|
+
for await (const chatEvent of response.sendMessageResponse) {
|
|
618
|
+
if (chatEvent.assistantResponseEvent?.content) {
|
|
619
|
+
responseContent += chatEvent.assistantResponseEvent.content;
|
|
620
|
+
if (responseContent.length > maxResponseSize) {
|
|
621
|
+
this.#features.logging.warn('LLM response exceeded size limit, truncating');
|
|
622
|
+
break;
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
return responseContent.trim();
|
|
628
|
+
}
|
|
629
|
+
catch (error) {
|
|
630
|
+
this.#features.logging.error(`Memory Bank LLM ranking failed: ${error}`);
|
|
631
|
+
return ''; // Empty string triggers TF-IDF fallback
|
|
632
|
+
}
|
|
633
|
+
});
|
|
634
|
+
// Only update prompt if we got a valid comprehensive prompt
|
|
635
|
+
if (comprehensivePrompt && comprehensivePrompt.trim().length > 0) {
|
|
636
|
+
params.prompt.prompt = comprehensivePrompt;
|
|
637
|
+
}
|
|
638
|
+
else {
|
|
639
|
+
this.#features.logging.warn('Empty comprehensive prompt received, using original prompt');
|
|
640
|
+
params.prompt.prompt = originalPrompt;
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
catch (error) {
|
|
644
|
+
this.#features.logging.error(`Memory Bank preparation failed: ${error}`);
|
|
645
|
+
// Restore original prompt to ensure no data loss
|
|
646
|
+
params.prompt.prompt = originalPrompt;
|
|
647
|
+
// Reset memory bank flag since preparation failed
|
|
648
|
+
session.isMemoryBankGeneration = false;
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
const maybeDefaultResponse = !params.prompt.command && (0, utils_1.getDefaultChatResponse)(params.prompt.prompt);
|
|
652
|
+
if (maybeDefaultResponse) {
|
|
653
|
+
return maybeDefaultResponse;
|
|
654
|
+
}
|
|
576
655
|
const compactIds = session.getAllDeferredCompactMessageIds();
|
|
577
656
|
await this.#invalidateCompactCommand(params.tabId, compactIds);
|
|
578
657
|
session.rejectAllDeferredToolExecutions(new toolShared_1.ToolApprovalException('Command ignored: new prompt', false));
|
|
@@ -619,7 +698,7 @@ class AgenticChatController {
|
|
|
619
698
|
await this.#telemetryController.emitAddMessageMetric(params.tabId, metric.metric, 'Cancelled');
|
|
620
699
|
});
|
|
621
700
|
session.setConversationType('AgenticChat');
|
|
622
|
-
const additionalContext = await this.#additionalContextProvider.getAdditionalContext(triggerContext, params.tabId, params.context);
|
|
701
|
+
const additionalContext = await this.#additionalContextProvider.getAdditionalContext(triggerContext, params.tabId, params.context, params.prompt.prompt);
|
|
623
702
|
// Add active file to context list if it's not already there
|
|
624
703
|
const activeFile = triggerContext.text &&
|
|
625
704
|
triggerContext.relativeFilePath &&
|
|
@@ -714,8 +793,7 @@ class AgenticChatController {
|
|
|
714
793
|
* Runs the compaction, making requests and processing tool uses until completion
|
|
715
794
|
*/
|
|
716
795
|
#shouldCompact(currentRequestCount) {
|
|
717
|
-
|
|
718
|
-
if (currentRequestCount > 456_000) {
|
|
796
|
+
if (currentRequestCount > constants_2.COMPACTION_CHARACTER_THRESHOLD) {
|
|
719
797
|
this.#debug(`Current request total character count is: ${currentRequestCount}, prompting user to compact`);
|
|
720
798
|
return true;
|
|
721
799
|
}
|
|
@@ -744,7 +822,7 @@ class AgenticChatController {
|
|
|
744
822
|
if (currentMessage) {
|
|
745
823
|
// Get and process the messages from history DB to maintain invariants for service requests
|
|
746
824
|
try {
|
|
747
|
-
const { history: historyMessages, historyCount: historyCharCount } = this.#chatHistoryDb.fixAndGetHistory(tabId,
|
|
825
|
+
const { history: historyMessages, historyCount: historyCharCount } = this.#chatHistoryDb.fixAndGetHistory(tabId, currentMessage, []);
|
|
748
826
|
messages = historyMessages;
|
|
749
827
|
characterCount = historyCharCount;
|
|
750
828
|
}
|
|
@@ -862,7 +940,7 @@ class AgenticChatController {
|
|
|
862
940
|
if (currentMessage) {
|
|
863
941
|
// Get and process the messages from history DB to maintain invariants for service requests
|
|
864
942
|
try {
|
|
865
|
-
const { history: historyMessages, historyCount: historyCharacterCount, currentCount: currentInputCount, } = this.#chatHistoryDb.fixAndGetHistory(tabId,
|
|
943
|
+
const { history: historyMessages, historyCount: historyCharacterCount, currentCount: currentInputCount, } = this.#chatHistoryDb.fixAndGetHistory(tabId, currentMessage, pinnedContextMessages);
|
|
866
944
|
messages = historyMessages;
|
|
867
945
|
currentRequestCount = currentInputCount + historyCharacterCount;
|
|
868
946
|
this.#debug(`Request total character count: ${currentRequestCount}`);
|
|
@@ -903,7 +981,7 @@ class AgenticChatController {
|
|
|
903
981
|
}
|
|
904
982
|
else {
|
|
905
983
|
this.#chatHistoryDb.addMessage(tabId, 'cwc', conversationIdentifier, {
|
|
906
|
-
body:
|
|
984
|
+
body: currentMessage.userInputMessage?.content ?? '',
|
|
907
985
|
type: 'prompt',
|
|
908
986
|
userIntent: currentMessage.userInputMessage?.userIntent,
|
|
909
987
|
origin: currentMessage.userInputMessage?.origin,
|
|
@@ -1245,7 +1323,9 @@ class AgenticChatController {
|
|
|
1245
1323
|
[toolConstants_1.FILE_SEARCH]: { Tool: fileSearch_1.FileSearch },
|
|
1246
1324
|
};
|
|
1247
1325
|
const { Tool } = toolMap[toolUse.name];
|
|
1248
|
-
const tool =
|
|
1326
|
+
const tool = toolUse.name === toolConstants_1.FS_READ && session.isMemoryBankGeneration
|
|
1327
|
+
? new Tool(this.#features, constants_2.FSREAD_MEMORY_BANK_MAX_PER_FILE, constants_2.FSREAD_MEMORY_BANK_MAX_TOTAL)
|
|
1328
|
+
: new Tool(this.#features);
|
|
1249
1329
|
// For MCP tools, get the permission from McpManager
|
|
1250
1330
|
// const permission = McpManager.instance.getToolPerm('Built-in', toolUse.name)
|
|
1251
1331
|
// If permission is 'alwaysAllow', we don't need to ask for acceptance
|
|
@@ -1351,6 +1431,25 @@ class AgenticChatController {
|
|
|
1351
1431
|
const ws = this.#getWritableStream(chatResultStream, toolUse);
|
|
1352
1432
|
const result = await this.#features.agent.runTool(toolUse.name, toolUse.input, token, ws);
|
|
1353
1433
|
let toolResultContent;
|
|
1434
|
+
if (toolUse.name === codeReview_1.CodeReview.toolName) {
|
|
1435
|
+
// no need to write tool result for code review, this is handled by model via chat
|
|
1436
|
+
// Push result in message so that it is picked by IDE plugin to show in issues panel
|
|
1437
|
+
const codeReviewResult = result;
|
|
1438
|
+
if (codeReviewResult?.output?.kind === 'json' &&
|
|
1439
|
+
codeReviewResult.output.success &&
|
|
1440
|
+
codeReviewResult.output.content?.findingsByFile) {
|
|
1441
|
+
await chatResultStream.writeResultBlock({
|
|
1442
|
+
type: 'tool',
|
|
1443
|
+
messageId: toolUse.toolUseId + codeReviewConstants_1.CODE_REVIEW_FINDINGS_MESSAGE_SUFFIX,
|
|
1444
|
+
body: codeReviewResult.output.content.findingsByFile,
|
|
1445
|
+
});
|
|
1446
|
+
codeReviewResult.output.content = {
|
|
1447
|
+
codeReviewId: codeReviewResult.output.content.codeReviewId,
|
|
1448
|
+
message: codeReviewResult.output.content.message,
|
|
1449
|
+
findingsByFileSimplified: codeReviewResult.output.content.findingsByFileSimplified,
|
|
1450
|
+
};
|
|
1451
|
+
}
|
|
1452
|
+
}
|
|
1354
1453
|
if (typeof result === 'string') {
|
|
1355
1454
|
toolResultContent = { text: result };
|
|
1356
1455
|
}
|
|
@@ -1422,18 +1521,6 @@ class AgenticChatController {
|
|
|
1422
1521
|
await chatResultStream.writeResultBlock(chatResult);
|
|
1423
1522
|
break;
|
|
1424
1523
|
case codeReview_1.CodeReview.toolName:
|
|
1425
|
-
// no need to write tool result for code review, this is handled by model via chat
|
|
1426
|
-
// Push result in message so that it is picked by IDE plugin to show in issues panel
|
|
1427
|
-
const codeReviewResult = result;
|
|
1428
|
-
if (codeReviewResult?.output?.kind === 'json' &&
|
|
1429
|
-
codeReviewResult.output.success &&
|
|
1430
|
-
codeReviewResult.output.content?.findingsByFile) {
|
|
1431
|
-
await chatResultStream.writeResultBlock({
|
|
1432
|
-
type: 'tool',
|
|
1433
|
-
messageId: toolUse.toolUseId + codeReviewConstants_1.CODE_REVIEW_FINDINGS_MESSAGE_SUFFIX,
|
|
1434
|
-
body: codeReviewResult.output.content.findingsByFile,
|
|
1435
|
-
});
|
|
1436
|
-
}
|
|
1437
1524
|
break;
|
|
1438
1525
|
case displayFindings_1.DisplayFindings.toolName:
|
|
1439
1526
|
// no need to write tool result for code review, this is handled by model via chat
|
|
@@ -1940,7 +2027,7 @@ class AgenticChatController {
|
|
|
1940
2027
|
body: constants_2.COMPACTION_HEADER_BODY,
|
|
1941
2028
|
buttons,
|
|
1942
2029
|
};
|
|
1943
|
-
const body = (0, constants_2.COMPACTION_BODY)(Math.round((characterCount /
|
|
2030
|
+
const body = (0, constants_2.COMPACTION_BODY)(Math.round((characterCount / constants_2.MAX_OVERALL_CHARACTERS) * 100));
|
|
1944
2031
|
return {
|
|
1945
2032
|
type: 'tool',
|
|
1946
2033
|
messageId,
|
|
@@ -2491,13 +2578,15 @@ class AgenticChatController {
|
|
|
2491
2578
|
.filter(prompt => prompt.length > 0)),
|
|
2492
2579
|
},
|
|
2493
2580
|
});
|
|
2581
|
+
// Reset memory bank flag after completion
|
|
2582
|
+
session.isMemoryBankGeneration = false;
|
|
2494
2583
|
return chatResultStream.getResult();
|
|
2495
2584
|
}
|
|
2496
2585
|
/**
|
|
2497
2586
|
* Handles errors that occur during the request
|
|
2498
2587
|
*/
|
|
2499
2588
|
async #handleRequestError(conversationId, err, errorMessageId, tabId, metric, agenticCodingMode) {
|
|
2500
|
-
const errorMessage = (0, utils_2.getErrorMsg)(err) ?? constants_2.GENERIC_ERROR_MS;
|
|
2589
|
+
const errorMessage = ((0, utils_2.getErrorMsg)(err) ?? constants_2.GENERIC_ERROR_MS).replace(/[\r\n]+/g, ' '); // replace new lines with empty space
|
|
2501
2590
|
const requestID = (0, utils_2.getRequestID)(err) ?? '';
|
|
2502
2591
|
metric.setDimension('cwsprChatResponseCode', (0, utils_2.getHttpStatusCode)(err) ?? 0);
|
|
2503
2592
|
metric.setDimension('languageServerVersion', this.#features.runtime.serverInfo.version);
|
|
@@ -2506,7 +2595,13 @@ class AgenticChatController {
|
|
|
2506
2595
|
metric.metric.requestIds = [requestID];
|
|
2507
2596
|
metric.metric.cwsprChatMessageId = errorMessageId;
|
|
2508
2597
|
metric.metric.cwsprChatConversationId = conversationId;
|
|
2509
|
-
|
|
2598
|
+
const errorCode = err.code ?? '';
|
|
2599
|
+
await this.#telemetryController.emitAddMessageMetric(tabId, metric.metric, 'Failed', errorMessage, errorCode);
|
|
2600
|
+
// Reset memory bank flag on request error
|
|
2601
|
+
const sessionResult = this.#chatSessionManagementService.getSession(tabId);
|
|
2602
|
+
if (sessionResult.success) {
|
|
2603
|
+
sessionResult.data.isMemoryBankGeneration = false;
|
|
2604
|
+
}
|
|
2510
2605
|
if ((0, utils_2.isUsageLimitError)(err)) {
|
|
2511
2606
|
if (this.#paidTierMode !== 'paidtier') {
|
|
2512
2607
|
this.setPaidTierMode(tabId, 'freetier-limit');
|