@aws/lsp-codewhisperer 0.0.74 → 0.0.76
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 +35 -0
- package/out/client/token/bearer-token-service.json +15 -0
- package/out/language-server/agenticChat/agenticChatController.d.ts +13 -2
- package/out/language-server/agenticChat/agenticChatController.js +162 -37
- package/out/language-server/agenticChat/agenticChatController.js.map +1 -1
- package/out/language-server/agenticChat/constants/modelSelection.d.ts +10 -2
- package/out/language-server/agenticChat/constants/modelSelection.js +11 -8
- package/out/language-server/agenticChat/constants/modelSelection.js.map +1 -1
- package/out/language-server/agenticChat/errors.d.ts +1 -1
- package/out/language-server/agenticChat/errors.js.map +1 -1
- package/out/language-server/agenticChat/tools/chatDb/chatDb.d.ts +10 -1
- package/out/language-server/agenticChat/tools/chatDb/chatDb.js +44 -0
- package/out/language-server/agenticChat/tools/chatDb/chatDb.js.map +1 -1
- package/out/language-server/agenticChat/tools/chatDb/util.d.ts +5 -1
- package/out/language-server/agenticChat/tools/chatDb/util.js +7 -0
- package/out/language-server/agenticChat/tools/chatDb/util.js.map +1 -1
- package/out/language-server/agenticChat/tools/mcp/mcpEventHandler.d.ts +1 -0
- package/out/language-server/agenticChat/tools/mcp/mcpEventHandler.js +50 -30
- package/out/language-server/agenticChat/tools/mcp/mcpEventHandler.js.map +1 -1
- package/out/language-server/agenticChat/tools/mcp/mcpManager.d.ts +4 -0
- package/out/language-server/agenticChat/tools/mcp/mcpManager.js +98 -52
- package/out/language-server/agenticChat/tools/mcp/mcpManager.js.map +1 -1
- package/out/language-server/agenticChat/tools/mcp/mcpOauthClient.d.ts +53 -0
- package/out/language-server/agenticChat/tools/mcp/mcpOauthClient.js +422 -0
- package/out/language-server/agenticChat/tools/mcp/mcpOauthClient.js.map +1 -0
- package/out/language-server/agenticChat/tools/mcp/mcpUtils.d.ts +4 -0
- package/out/language-server/agenticChat/tools/mcp/mcpUtils.js +89 -69
- package/out/language-server/agenticChat/tools/mcp/mcpUtils.js.map +1 -1
- package/out/language-server/agenticChat/tools/qCodeAnalysis/codeReview.js +15 -1
- package/out/language-server/agenticChat/tools/qCodeAnalysis/codeReview.js.map +1 -1
- package/out/language-server/agenticChat/tools/qCodeAnalysis/codeReviewSchemas.d.ts +4 -4
- package/out/language-server/agenticChat/tools/qCodeAnalysis/codeReviewTypes.d.ts +2 -1
- package/out/language-server/agenticChat/tools/qCodeAnalysis/codeReviewTypes.js +1 -0
- package/out/language-server/agenticChat/tools/qCodeAnalysis/codeReviewTypes.js.map +1 -1
- package/out/language-server/agenticChat/tools/qCodeAnalysis/displayFindingsSchemas.d.ts +16 -16
- package/out/language-server/inline-completion/codeWhispererServer.js +13 -14
- package/out/language-server/inline-completion/codeWhispererServer.js.map +1 -1
- package/out/language-server/inline-completion/editCompletionHandler.d.ts +1 -0
- package/out/language-server/inline-completion/editCompletionHandler.js +7 -3
- package/out/language-server/inline-completion/editCompletionHandler.js.map +1 -1
- package/out/language-server/inline-completion/session/sessionManager.d.ts +0 -3
- package/out/language-server/inline-completion/session/sessionManager.js +0 -19
- package/out/language-server/inline-completion/session/sessionManager.js.map +1 -1
- package/out/language-server/inline-completion/tracker/streakTracker.d.ts +21 -0
- package/out/language-server/inline-completion/tracker/streakTracker.js +43 -0
- package/out/language-server/inline-completion/tracker/streakTracker.js.map +1 -0
- package/out/shared/amazonQServiceManager/AmazonQTokenServiceManager.js +3 -0
- package/out/shared/amazonQServiceManager/AmazonQTokenServiceManager.js.map +1 -1
- package/out/shared/codeWhispererService.d.ts +4 -0
- package/out/shared/codeWhispererService.js +6 -0
- package/out/shared/codeWhispererService.js.map +1 -1
- package/out/shared/constants.d.ts +1 -0
- package/out/shared/constants.js +2 -1
- package/out/shared/constants.js.map +1 -1
- package/out/shared/supplementalContextUtil/crossFileContextUtil.js +10 -1
- package/out/shared/supplementalContextUtil/crossFileContextUtil.js.map +1 -1
- package/package.json +2 -2
- package/out/language-server/agenticChat/utils/agenticChatControllerHelper.d.ts +0 -8
- package/out/language-server/agenticChat/utils/agenticChatControllerHelper.js +0 -15
- package/out/language-server/agenticChat/utils/agenticChatControllerHelper.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,40 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.76](https://github.com/aws/language-servers/compare/lsp-codewhisperer/v0.0.75...lsp-codewhisperer/v0.0.76) (2025-08-27)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add basic OAuth client for remote MCP ([#2136](https://github.com/aws/language-servers/issues/2136)) ([2fb896e](https://github.com/aws/language-servers/commit/2fb896e094de0bc5a1b4881067e7dcceb3826015))
|
|
9
|
+
* **amazonq:** emit metric for each issue ([#2179](https://github.com/aws/language-servers/issues/2179)) ([5a3f481](https://github.com/aws/language-servers/commit/5a3f481ebe8c6033e3833abcd81799d26c2aa03e))
|
|
10
|
+
* Auto fetch models from listAvailableModels API ([#2171](https://github.com/aws/language-servers/issues/2171)) ([8600c52](https://github.com/aws/language-servers/commit/8600c524877abb459e9338399352446c0dcff6f0))
|
|
11
|
+
* disable pkce flow during plugin load ([#2153](https://github.com/aws/language-servers/issues/2153)) ([71b3595](https://github.com/aws/language-servers/commit/71b35952333e7581921644ce40fabbc1e6d3c02f))
|
|
12
|
+
* update MCP manager and utilities ([#2158](https://github.com/aws/language-servers/issues/2158)) ([b99df82](https://github.com/aws/language-servers/commit/b99df82826d0ba1a1d52df578cb80674c90505b9))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* adding streakTracker to track streakLength across Completions and Edits ([#2147](https://github.com/aws/language-servers/issues/2147)) ([a6c64f2](https://github.com/aws/language-servers/commit/a6c64f2995a17697e3d71d30a1f411f5cf0db279))
|
|
18
|
+
* **amazonq:** dedupe openTabs supplemental contexts ([#2172](https://github.com/aws/language-servers/issues/2172)) ([aa87ae2](https://github.com/aws/language-servers/commit/aa87ae2bd95edc1f38bf90f56093c5bf5ff18c53))
|
|
19
|
+
* **amazonq:** fix for mcp servers operations to edit server config only ([#2165](https://github.com/aws/language-servers/issues/2165)) ([d28df09](https://github.com/aws/language-servers/commit/d28df09ae41871430cd53064eac1f3050c95ea84))
|
|
20
|
+
* **amazonq:** fix to add mcp server tool error handling and status for card ([#2176](https://github.com/aws/language-servers/issues/2176)) ([23f5ec3](https://github.com/aws/language-servers/commit/23f5ec343cb4e0de32926204dbcf99e51af829f9))
|
|
21
|
+
* **amazonq:** status message update for mcp tool permission accpetance ([#2178](https://github.com/aws/language-servers/issues/2178)) ([4893344](https://github.com/aws/language-servers/commit/489334466fa084774d6e4737569468d654dc6359))
|
|
22
|
+
* fix pkce windows url path ([#2173](https://github.com/aws/language-servers/issues/2173)) ([d7b184c](https://github.com/aws/language-servers/commit/d7b184cb12979877722fa0293e9aebec91ff2c18))
|
|
23
|
+
* multiple fixes on auth flow edge cases ([#2155](https://github.com/aws/language-servers/issues/2155)) ([472220a](https://github.com/aws/language-servers/commit/472220a745cff4fe91a2cabae4ae059a164ceddd))
|
|
24
|
+
* reduce auto trigger frequency for VSC ([#2168](https://github.com/aws/language-servers/issues/2168)) ([00e11ff](https://github.com/aws/language-servers/commit/00e11ff48eafaa0baec48177fa4aa6d60048af2f))
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
### Reverts
|
|
28
|
+
|
|
29
|
+
* reduce auto trigger frequency for VSC ([#2168](https://github.com/aws/language-servers/issues/2168))" ([#2177](https://github.com/aws/language-servers/issues/2177)) ([08720c6](https://github.com/aws/language-servers/commit/08720c6c3fa83f9b3b6775d4ae4d848ce145b94b))
|
|
30
|
+
|
|
31
|
+
## [0.0.75](https://github.com/aws/language-servers/compare/lsp-codewhisperer/v0.0.74...lsp-codewhisperer/v0.0.75) (2025-08-21)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
### Bug Fixes
|
|
35
|
+
|
|
36
|
+
* **amazonq:** don't let flare send discard for the still valid suggestion in JB ([#2145](https://github.com/aws/language-servers/issues/2145)) ([0767e07](https://github.com/aws/language-servers/commit/0767e074c91682a91d2fe7a6b2a7369c4dea280c))
|
|
37
|
+
|
|
3
38
|
## [0.0.74](https://github.com/aws/language-servers/compare/lsp-codewhisperer/v0.0.73...lsp-codewhisperer/v0.0.74) (2025-08-19)
|
|
4
39
|
|
|
5
40
|
|
|
@@ -3622,6 +3622,10 @@
|
|
|
3622
3622
|
"shape": "Models",
|
|
3623
3623
|
"documentation": "<p>List of available models</p>"
|
|
3624
3624
|
},
|
|
3625
|
+
"defaultModel": {
|
|
3626
|
+
"shape": "Model",
|
|
3627
|
+
"documentation": "<p>Default model set by the client</p>"
|
|
3628
|
+
},
|
|
3625
3629
|
"nextToken": {
|
|
3626
3630
|
"shape": "Base64EncodedPaginationToken",
|
|
3627
3631
|
"documentation": "<p>Token for retrieving the next page of results</p>"
|
|
@@ -3955,6 +3959,10 @@
|
|
|
3955
3959
|
"shape": "ModelId",
|
|
3956
3960
|
"documentation": "<p>Unique identifier for the model</p>"
|
|
3957
3961
|
},
|
|
3962
|
+
"modelName": {
|
|
3963
|
+
"shape": "ModelName",
|
|
3964
|
+
"documentation": "<p>User-facing display name</p>"
|
|
3965
|
+
},
|
|
3958
3966
|
"description": {
|
|
3959
3967
|
"shape": "Description",
|
|
3960
3968
|
"documentation": "<p>Description of the model</p>"
|
|
@@ -3972,6 +3980,13 @@
|
|
|
3972
3980
|
"min": 1,
|
|
3973
3981
|
"pattern": "[a-zA-Z0-9_:.-]+"
|
|
3974
3982
|
},
|
|
3983
|
+
"ModelName": {
|
|
3984
|
+
"type": "string",
|
|
3985
|
+
"documentation": "<p>Identifier for the model Name</p>",
|
|
3986
|
+
"max": 1024,
|
|
3987
|
+
"min": 1,
|
|
3988
|
+
"pattern": "[a-zA-Z0-9-_.]+"
|
|
3989
|
+
},
|
|
3975
3990
|
"ModelMetadata": {
|
|
3976
3991
|
"type": "structure",
|
|
3977
3992
|
"members": {
|
|
@@ -4,8 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { ToolResult, ToolUse } from '@amzn/codewhisperer-streaming';
|
|
6
6
|
import { ChatCommandInput } from '../../shared/streamingClientService';
|
|
7
|
-
import { Status, ButtonClickParams, ButtonClickResult, InlineChatResultParams, PromptInputOptionChangeParams, RuleClickParams, ListRulesParams, ActiveEditorChangedParams, PinnedContextParams, ExecuteCommandParams, FollowUpClickParams, ListAvailableModelsParams, ListAvailableModelsResult, OpenFileDialogParams, OpenFileDialogResult } from '@aws/language-server-runtimes/protocol';
|
|
8
|
-
import { FeedbackParams, InsertToCursorPositionParams, InlineChatParams, ConversationClickParams, ListConversationsParams, ListMcpServersParams, McpServerClickParams, TabBarActionParams, CreatePromptParams, FileClickParams } from '@aws/language-server-runtimes/protocol';
|
|
7
|
+
import { Status, ButtonClickParams, ButtonClickResult, InlineChatResultParams, PromptInputOptionChangeParams, RuleClickParams, ListRulesParams, ActiveEditorChangedParams, PinnedContextParams, ExecuteCommandParams, FollowUpClickParams, ListAvailableModelsParams, ListAvailableModelsResult, OpenFileDialogParams, OpenFileDialogResult, FeedbackParams, InsertToCursorPositionParams, InlineChatParams, ConversationClickParams, ListConversationsParams, ListMcpServersParams, McpServerClickParams, TabBarActionParams, CreatePromptParams, FileClickParams } from '@aws/language-server-runtimes/protocol';
|
|
9
8
|
import { CancellationToken, Chat, ChatParams, ChatResult, EndChatParams, QuickActionParams, ResponseError, TabAddParams, TabRemoveParams, TabChangeParams, InlineChatResult } from '@aws/language-server-runtimes/server-interface';
|
|
10
9
|
import { Features, LspHandlers } from '../types';
|
|
11
10
|
import { ChatSessionManagementService } from '../chat/chatSessionManagementService';
|
|
@@ -54,6 +53,18 @@ export declare class AgenticChatController implements ChatHandlers {
|
|
|
54
53
|
list: import("@aws/language-server-runtimes/protocol").DetailedListGroup[];
|
|
55
54
|
}>;
|
|
56
55
|
onMcpServerClick(params: McpServerClickParams): Promise<any>;
|
|
56
|
+
/**
|
|
57
|
+
* This function handles the model selection process for the chat interface.
|
|
58
|
+
* It first attempts to retrieve models from cache or API, then determines the appropriate model to select
|
|
59
|
+
* based on the following priority:
|
|
60
|
+
* 1. When errors occur or session is invalid: Use the default model as a fallback
|
|
61
|
+
* 2. When user has previously selected a model: Use that model (or its mapped version if the model ID has changed)
|
|
62
|
+
* 3. When there's a default model from the API: Use the server-recommended default model
|
|
63
|
+
* 4. Last resort: Use the newest model defined in modelSelection constants
|
|
64
|
+
*
|
|
65
|
+
* This ensures users maintain consistent model selection across sessions while also handling
|
|
66
|
+
* API failures and model ID migrations gracefully.
|
|
67
|
+
*/
|
|
57
68
|
onListAvailableModels(params: ListAvailableModelsParams): Promise<ListAvailableModelsResult>;
|
|
58
69
|
onChatPrompt(params: ChatParams, token: CancellationToken): Promise<ChatResult | ResponseError<ChatResult>>;
|
|
59
70
|
truncatePinnedContext(remainingCharacterBudget: number, pinnedContext?: AdditionalContentEntryAddition[]): number;
|
|
@@ -11,7 +11,6 @@ const os = require("os");
|
|
|
11
11
|
const codewhisperer_streaming_1 = require("@amzn/codewhisperer-streaming");
|
|
12
12
|
const toolConstants_1 = require("./constants/toolConstants");
|
|
13
13
|
const protocol_1 = require("@aws/language-server-runtimes/protocol");
|
|
14
|
-
const protocol_2 = require("@aws/language-server-runtimes/protocol");
|
|
15
14
|
const server_interface_1 = require("@aws/language-server-runtimes/server-interface");
|
|
16
15
|
const uuid_1 = require("uuid");
|
|
17
16
|
const types_1 = require("../../shared/telemetry/types");
|
|
@@ -62,9 +61,9 @@ const util_1 = require("./tools/chatDb/util");
|
|
|
62
61
|
const modelSelection_1 = require("./constants/modelSelection");
|
|
63
62
|
const imageVerification_1 = require("../../shared/imageVerification");
|
|
64
63
|
const path_1 = require("@aws/lsp-core/out/util/path");
|
|
65
|
-
const agenticChatControllerHelper_1 = require("./utils/agenticChatControllerHelper");
|
|
66
64
|
const activeUserTracker_1 = require("../../shared/activeUserTracker");
|
|
67
65
|
const displayFindings_1 = require("./tools/qCodeAnalysis/displayFindings");
|
|
66
|
+
const constants_3 = require("../../shared/constants");
|
|
68
67
|
const IdleWorkspaceManager_1 = require("../workspaceContext/IdleWorkspaceManager");
|
|
69
68
|
class AgenticChatController {
|
|
70
69
|
#features;
|
|
@@ -145,7 +144,7 @@ class AgenticChatController {
|
|
|
145
144
|
// @ts-ignore
|
|
146
145
|
this.#features.chat.chatOptionsUpdate({ region });
|
|
147
146
|
});
|
|
148
|
-
this.#chatHistoryDb =
|
|
147
|
+
this.#chatHistoryDb = chatDb_1.ChatDatabase.getInstance(features);
|
|
149
148
|
this.#tabBarController = new tabBarController_1.TabBarController(features, this.#chatHistoryDb, telemetryService, (tabId) => this.sendPinnedContext(tabId));
|
|
150
149
|
this.#additionalContextProvider = new additionalContextProvider_1.AdditionalContextProvider(features, this.#chatHistoryDb);
|
|
151
150
|
this.#contextCommandsProvider = new contextCommandsProvider_1.ContextCommandsProvider(this.#features.logging, this.#features.chat, this.#features.workspace, this.#features.lsp);
|
|
@@ -431,21 +430,116 @@ class AgenticChatController {
|
|
|
431
430
|
async onMcpServerClick(params) {
|
|
432
431
|
return this.#mcpEventHandler.onMcpServerClick(params);
|
|
433
432
|
}
|
|
433
|
+
/**
|
|
434
|
+
* Fetches available models either from cache or API
|
|
435
|
+
* If cache is valid (less than 5 minutes old), returns cached models
|
|
436
|
+
* If cache is invalid or empty, makes an API call and stores results in cache
|
|
437
|
+
* If the API throws errors (e.g., throttling), falls back to default models
|
|
438
|
+
*/
|
|
439
|
+
async #fetchModelsWithCache() {
|
|
440
|
+
let models = [];
|
|
441
|
+
let defaultModelId;
|
|
442
|
+
let errorFromAPI = false;
|
|
443
|
+
// Check if cache is valid (less than 5 minutes old)
|
|
444
|
+
if (this.#chatHistoryDb.isCachedModelsValid()) {
|
|
445
|
+
const cachedData = this.#chatHistoryDb.getCachedModels();
|
|
446
|
+
if (cachedData && cachedData.models && cachedData.models.length > 0) {
|
|
447
|
+
this.#log('Using cached models, last updated at:', new Date(cachedData.timestamp).toISOString());
|
|
448
|
+
return {
|
|
449
|
+
models: cachedData.models,
|
|
450
|
+
defaultModelId: cachedData.defaultModelId,
|
|
451
|
+
errorFromAPI: false,
|
|
452
|
+
};
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
// If cache is invalid or empty, make an API call
|
|
456
|
+
this.#log('Cache miss or expired, fetching models from API');
|
|
457
|
+
try {
|
|
458
|
+
const client = AmazonQTokenServiceManager_1.AmazonQTokenServiceManager.getInstance().getCodewhispererService();
|
|
459
|
+
const responseResult = await client.listAvailableModels({
|
|
460
|
+
origin: constants_3.IDE,
|
|
461
|
+
profileArn: AmazonQTokenServiceManager_1.AmazonQTokenServiceManager.getInstance().getConnectionType()
|
|
462
|
+
? AmazonQTokenServiceManager_1.AmazonQTokenServiceManager.getInstance().getActiveProfileArn()
|
|
463
|
+
: undefined,
|
|
464
|
+
});
|
|
465
|
+
// Wait for the response to be completed before proceeding
|
|
466
|
+
this.#log('Model Response: ', JSON.stringify(responseResult, null, 2));
|
|
467
|
+
models = Object.values(responseResult.models).map(({ modelId, modelName }) => ({
|
|
468
|
+
id: modelId,
|
|
469
|
+
name: modelName ?? modelId,
|
|
470
|
+
}));
|
|
471
|
+
defaultModelId = responseResult.defaultModel?.modelId;
|
|
472
|
+
// Cache the models with defaultModelId
|
|
473
|
+
this.#chatHistoryDb.setCachedModels(models, defaultModelId);
|
|
474
|
+
}
|
|
475
|
+
catch (err) {
|
|
476
|
+
// In case of API throttling or other errors, fall back to hardcoded models
|
|
477
|
+
this.#log('Error fetching models from API, using fallback models:', (0, utils_2.fmtError)(err));
|
|
478
|
+
errorFromAPI = true;
|
|
479
|
+
models = modelSelection_1.FALLBACK_MODEL_OPTIONS;
|
|
480
|
+
}
|
|
481
|
+
return {
|
|
482
|
+
models,
|
|
483
|
+
defaultModelId,
|
|
484
|
+
errorFromAPI,
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
/**
|
|
488
|
+
* This function handles the model selection process for the chat interface.
|
|
489
|
+
* It first attempts to retrieve models from cache or API, then determines the appropriate model to select
|
|
490
|
+
* based on the following priority:
|
|
491
|
+
* 1. When errors occur or session is invalid: Use the default model as a fallback
|
|
492
|
+
* 2. When user has previously selected a model: Use that model (or its mapped version if the model ID has changed)
|
|
493
|
+
* 3. When there's a default model from the API: Use the server-recommended default model
|
|
494
|
+
* 4. Last resort: Use the newest model defined in modelSelection constants
|
|
495
|
+
*
|
|
496
|
+
* This ensures users maintain consistent model selection across sessions while also handling
|
|
497
|
+
* API failures and model ID migrations gracefully.
|
|
498
|
+
*/
|
|
434
499
|
async onListAvailableModels(params) {
|
|
435
|
-
|
|
436
|
-
const models
|
|
500
|
+
// Get models from cache or API
|
|
501
|
+
const { models, defaultModelId, errorFromAPI } = await this.#fetchModelsWithCache();
|
|
502
|
+
// Get the first fallback model option as default
|
|
503
|
+
const defaultModelOption = modelSelection_1.FALLBACK_MODEL_OPTIONS[1];
|
|
504
|
+
const DEFAULT_MODEL_ID = defaultModelId || defaultModelOption?.id;
|
|
437
505
|
const sessionResult = this.#chatSessionManagementService.getSession(params.tabId);
|
|
438
506
|
const { data: session, success } = sessionResult;
|
|
439
|
-
|
|
507
|
+
// Handle error cases by returning default model
|
|
508
|
+
if (!success || errorFromAPI) {
|
|
440
509
|
return {
|
|
441
510
|
tabId: params.tabId,
|
|
442
511
|
models: models,
|
|
512
|
+
selectedModelId: DEFAULT_MODEL_ID,
|
|
443
513
|
};
|
|
444
514
|
}
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
515
|
+
// Determine selected model ID based on priority
|
|
516
|
+
let selectedModelId;
|
|
517
|
+
let modelId = this.#chatHistoryDb.getModelId();
|
|
518
|
+
// Helper function to get model label from FALLBACK_MODEL_RECORD
|
|
519
|
+
const getModelLabel = (modelKey) => modelSelection_1.FALLBACK_MODEL_RECORD[modelKey]?.label || modelKey;
|
|
520
|
+
// Helper function to map enum model ID to API model ID
|
|
521
|
+
const getMappedModelId = (modelKey) => modelSelection_1.BEDROCK_MODEL_TO_MODEL_ID[modelKey] || modelKey;
|
|
522
|
+
// Determine selected model ID based on priority
|
|
523
|
+
if (modelId) {
|
|
524
|
+
const mappedModelId = getMappedModelId(modelId);
|
|
525
|
+
// Priority 1: Use mapped modelId if it exists in available models from backend
|
|
526
|
+
if (models.some(model => model.id === mappedModelId)) {
|
|
527
|
+
selectedModelId = mappedModelId;
|
|
528
|
+
}
|
|
529
|
+
// Priority 2: Use mapped version if modelId exists in FALLBACK_MODEL_RECORD and no backend models available
|
|
530
|
+
else if (models.length === 0 && modelId in modelSelection_1.FALLBACK_MODEL_RECORD) {
|
|
531
|
+
selectedModelId = getModelLabel(modelId);
|
|
532
|
+
}
|
|
533
|
+
// Priority 3: Fall back to default or system default
|
|
534
|
+
else {
|
|
535
|
+
selectedModelId = defaultModelId || getMappedModelId(DEFAULT_MODEL_ID);
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
else {
|
|
539
|
+
// No user-selected model - use API default or system default
|
|
540
|
+
selectedModelId = defaultModelId || getMappedModelId(DEFAULT_MODEL_ID);
|
|
541
|
+
}
|
|
542
|
+
// Store the selected model in the session
|
|
449
543
|
session.modelId = selectedModelId;
|
|
450
544
|
return {
|
|
451
545
|
tabId: params.tabId,
|
|
@@ -474,7 +568,7 @@ class AgenticChatController {
|
|
|
474
568
|
const sessionResult = this.#chatSessionManagementService.getSession(params.tabId);
|
|
475
569
|
const { data: session, success } = sessionResult;
|
|
476
570
|
if (!success) {
|
|
477
|
-
return new server_interface_1.ResponseError(
|
|
571
|
+
return new server_interface_1.ResponseError(protocol_1.ErrorCodes.InternalError, sessionResult.error);
|
|
478
572
|
}
|
|
479
573
|
const compactIds = session.getAllDeferredCompactMessageIds();
|
|
480
574
|
await this.#invalidateCompactCommand(params.tabId, compactIds);
|
|
@@ -1400,6 +1494,48 @@ class AgenticChatController {
|
|
|
1400
1494
|
// only emit if this is an actual tool error (not a user rejecting/canceling tool)
|
|
1401
1495
|
this.#telemetryController.emitToolUseSuggested(toolUse, session.conversationId ?? '', this.#features.runtime.serverInfo.version ?? '', undefined, session.pairProgrammingMode, this.#abTestingAllocation?.experimentName, this.#abTestingAllocation?.userVariation, 'Failed');
|
|
1402
1496
|
}
|
|
1497
|
+
// Handle MCP tool failures
|
|
1498
|
+
const originalNames = mcpManager_1.McpManager.instance.getOriginalToolNames(toolUse.name);
|
|
1499
|
+
if (originalNames && toolUse.toolUseId) {
|
|
1500
|
+
const { toolName } = originalNames;
|
|
1501
|
+
const cachedToolUse = session.toolUseLookup.get(toolUse.toolUseId);
|
|
1502
|
+
const cachedButtonBlockId = cachedToolUse?.cachedButtonBlockId;
|
|
1503
|
+
const customerFacingError = (0, errors_2.getCustomerFacingErrorMessage)(err);
|
|
1504
|
+
const errorResult = {
|
|
1505
|
+
type: 'tool',
|
|
1506
|
+
messageId: toolUse.toolUseId,
|
|
1507
|
+
summary: {
|
|
1508
|
+
content: {
|
|
1509
|
+
header: {
|
|
1510
|
+
icon: 'tools',
|
|
1511
|
+
body: `${toolName}`,
|
|
1512
|
+
status: {
|
|
1513
|
+
status: 'error',
|
|
1514
|
+
icon: 'cancel-circle',
|
|
1515
|
+
text: 'Error',
|
|
1516
|
+
description: customerFacingError,
|
|
1517
|
+
},
|
|
1518
|
+
},
|
|
1519
|
+
},
|
|
1520
|
+
collapsedContent: [
|
|
1521
|
+
{
|
|
1522
|
+
header: { body: 'Parameters' },
|
|
1523
|
+
body: `\`\`\`json\n${JSON.stringify(toolUse.input, null, 2)}\n\`\`\``,
|
|
1524
|
+
},
|
|
1525
|
+
{
|
|
1526
|
+
header: { body: 'Error' },
|
|
1527
|
+
body: customerFacingError,
|
|
1528
|
+
},
|
|
1529
|
+
],
|
|
1530
|
+
},
|
|
1531
|
+
};
|
|
1532
|
+
if (cachedButtonBlockId !== undefined) {
|
|
1533
|
+
await chatResultStream.overwriteResultBlock(errorResult, cachedButtonBlockId);
|
|
1534
|
+
}
|
|
1535
|
+
else {
|
|
1536
|
+
await chatResultStream.writeResultBlock(errorResult);
|
|
1537
|
+
}
|
|
1538
|
+
}
|
|
1403
1539
|
// display fs write failure status in the UX of that file card
|
|
1404
1540
|
if ((toolUse.name === toolConstants_1.FS_WRITE || toolUse.name === toolConstants_1.FS_REPLACE) && toolUse.toolUseId) {
|
|
1405
1541
|
const existingCard = chatResultStream.getMessageBlockId(toolUse.toolUseId);
|
|
@@ -1729,7 +1865,7 @@ class AgenticChatController {
|
|
|
1729
1865
|
status: {
|
|
1730
1866
|
status: isAccept ? 'success' : 'error',
|
|
1731
1867
|
icon: isAccept ? 'ok' : 'cancel',
|
|
1732
|
-
text: isAccept ? '
|
|
1868
|
+
text: isAccept ? 'Accepted' : 'Rejected',
|
|
1733
1869
|
},
|
|
1734
1870
|
fileList: undefined,
|
|
1735
1871
|
},
|
|
@@ -2554,8 +2690,8 @@ class AgenticChatController {
|
|
|
2554
2690
|
const workspaceEdit = {
|
|
2555
2691
|
edit: {
|
|
2556
2692
|
documentChanges: [
|
|
2557
|
-
|
|
2558
|
-
|
|
2693
|
+
protocol_1.TextDocumentEdit.create({ uri: params.textDocument.uri, version: 0 }, [
|
|
2694
|
+
protocol_1.TextEdit.insert(cursorPosition, textWithIndent),
|
|
2559
2695
|
]),
|
|
2560
2696
|
],
|
|
2561
2697
|
},
|
|
@@ -2639,23 +2775,6 @@ class AgenticChatController {
|
|
|
2639
2775
|
});
|
|
2640
2776
|
}
|
|
2641
2777
|
onSourceLinkClick() { }
|
|
2642
|
-
/**
|
|
2643
|
-
* @deprecated use aws/chat/listAvailableModels server request instead
|
|
2644
|
-
*/
|
|
2645
|
-
#legacySetModelId(tabId, session) {
|
|
2646
|
-
// Since model selection is mandatory, the only time modelId is not set is when the chat history is empty.
|
|
2647
|
-
// In that case, we use the default modelId.
|
|
2648
|
-
let modelId = this.#chatHistoryDb.getModelId() ?? constants_2.DEFAULT_MODEL_ID;
|
|
2649
|
-
const region = AmazonQTokenServiceManager_1.AmazonQTokenServiceManager.getInstance().getRegion();
|
|
2650
|
-
if (region === 'eu-central-1') {
|
|
2651
|
-
// Only 3.7 Sonnet is available in eu-central-1 for now
|
|
2652
|
-
modelId = 'CLAUDE_3_7_SONNET_20250219_V1_0';
|
|
2653
|
-
// @ts-ignore
|
|
2654
|
-
this.#features.chat.chatOptionsUpdate({ region });
|
|
2655
|
-
}
|
|
2656
|
-
this.#features.chat.chatOptionsUpdate({ modelId: modelId, tabId: tabId });
|
|
2657
|
-
session.modelId = modelId;
|
|
2658
|
-
}
|
|
2659
2778
|
onTabAdd(params) {
|
|
2660
2779
|
this.#telemetryController.activeTabId = params.tabId;
|
|
2661
2780
|
if (!params.restoredTab) {
|
|
@@ -2664,22 +2783,21 @@ class AgenticChatController {
|
|
|
2664
2783
|
const sessionResult = this.#chatSessionManagementService.createSession(params.tabId);
|
|
2665
2784
|
const { data: session, success } = sessionResult;
|
|
2666
2785
|
if (!success) {
|
|
2667
|
-
return new server_interface_1.ResponseError(
|
|
2786
|
+
return new server_interface_1.ResponseError(protocol_1.ErrorCodes.InternalError, sessionResult.error);
|
|
2668
2787
|
}
|
|
2669
|
-
this.#legacySetModelId(params.tabId, session);
|
|
2670
2788
|
// Get the saved pair programming mode from the database or default to true if not found
|
|
2671
2789
|
const savedPairProgrammingMode = this.#chatHistoryDb.getPairProgrammingMode();
|
|
2672
2790
|
session.pairProgrammingMode = savedPairProgrammingMode !== undefined ? savedPairProgrammingMode : true;
|
|
2791
|
+
if (session) {
|
|
2792
|
+
// Set the logging object on the session
|
|
2793
|
+
session.setLogging(this.#features.logging);
|
|
2794
|
+
}
|
|
2673
2795
|
// Update the client with the initial pair programming mode
|
|
2674
2796
|
this.#features.chat.chatOptionsUpdate({
|
|
2675
2797
|
tabId: params.tabId,
|
|
2676
2798
|
// Type assertion to support pairProgrammingMode
|
|
2677
2799
|
...(session.pairProgrammingMode !== undefined ? { pairProgrammingMode: session.pairProgrammingMode } : {}),
|
|
2678
2800
|
});
|
|
2679
|
-
if (success && session) {
|
|
2680
|
-
// Set the logging object on the session
|
|
2681
|
-
session.setLogging(this.#features.logging);
|
|
2682
|
-
}
|
|
2683
2801
|
this.setPaidTierMode(params.tabId);
|
|
2684
2802
|
}
|
|
2685
2803
|
onTabChange(params) {
|
|
@@ -3393,6 +3511,13 @@ class AgenticChatController {
|
|
|
3393
3511
|
}
|
|
3394
3512
|
else {
|
|
3395
3513
|
// Fallback to creating a new card
|
|
3514
|
+
if (toolResultCard.summary?.content?.header) {
|
|
3515
|
+
toolResultCard.summary.content.header.status = {
|
|
3516
|
+
status: 'success',
|
|
3517
|
+
icon: 'ok',
|
|
3518
|
+
text: 'Completed',
|
|
3519
|
+
};
|
|
3520
|
+
}
|
|
3396
3521
|
this.#log(`Warning: No blockId found for tool use ${toolUse.toolUseId}, creating new card`);
|
|
3397
3522
|
await chatResultStream.writeResultBlock(toolResultCard);
|
|
3398
3523
|
}
|