@aws/lsp-codewhisperer 0.0.83 → 0.0.84

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.
Files changed (85) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/out/language-server/agenticChat/agenticChatController.js +62 -9
  3. package/out/language-server/agenticChat/agenticChatController.js.map +1 -1
  4. package/out/language-server/agenticChat/agenticChatResultStream.d.ts +1 -0
  5. package/out/language-server/agenticChat/agenticChatResultStream.js +21 -0
  6. package/out/language-server/agenticChat/agenticChatResultStream.js.map +1 -1
  7. package/out/language-server/agenticChat/constants/constants.d.ts +23 -0
  8. package/out/language-server/agenticChat/constants/constants.js +32 -1
  9. package/out/language-server/agenticChat/constants/constants.js.map +1 -1
  10. package/out/language-server/agenticChat/constants/modelSelection.d.ts +2 -2
  11. package/out/language-server/agenticChat/constants/modelSelection.js +6 -5
  12. package/out/language-server/agenticChat/constants/modelSelection.js.map +1 -1
  13. package/out/language-server/agenticChat/context/agenticChatTriggerContext.d.ts +2 -1
  14. package/out/language-server/agenticChat/context/agenticChatTriggerContext.js +3 -1
  15. package/out/language-server/agenticChat/context/agenticChatTriggerContext.js.map +1 -1
  16. package/out/language-server/agenticChat/retry/delayInterceptor.d.ts +33 -0
  17. package/out/language-server/agenticChat/retry/delayInterceptor.js +79 -0
  18. package/out/language-server/agenticChat/retry/delayInterceptor.js.map +1 -0
  19. package/out/language-server/agenticChat/retry/errorTransformer.d.ts +15 -0
  20. package/out/language-server/agenticChat/retry/errorTransformer.js +152 -0
  21. package/out/language-server/agenticChat/retry/errorTransformer.js.map +1 -0
  22. package/out/language-server/agenticChat/retry/index.d.ts +3 -0
  23. package/out/language-server/agenticChat/retry/index.js +11 -0
  24. package/out/language-server/agenticChat/retry/index.js.map +1 -0
  25. package/out/language-server/agenticChat/retry/qRetryStrategy.d.ts +20 -0
  26. package/out/language-server/agenticChat/retry/qRetryStrategy.js +71 -0
  27. package/out/language-server/agenticChat/retry/qRetryStrategy.js.map +1 -0
  28. package/out/language-server/agenticChat/retry/retryClassifier.d.ts +32 -0
  29. package/out/language-server/agenticChat/retry/retryClassifier.js +122 -0
  30. package/out/language-server/agenticChat/retry/retryClassifier.js.map +1 -0
  31. package/out/language-server/agenticChat/tabBarController.d.ts +4 -0
  32. package/out/language-server/agenticChat/tabBarController.js +19 -2
  33. package/out/language-server/agenticChat/tabBarController.js.map +1 -1
  34. package/out/language-server/chat/chatController.js.map +1 -1
  35. package/out/language-server/chat/chatSessionService.d.ts +7 -0
  36. package/out/language-server/chat/chatSessionService.js +37 -80
  37. package/out/language-server/chat/chatSessionService.js.map +1 -1
  38. package/out/language-server/chat/constants.d.ts +1 -0
  39. package/out/language-server/chat/constants.js +2 -1
  40. package/out/language-server/chat/constants.js.map +1 -1
  41. package/out/language-server/chat/telemetry/chatTelemetryController.d.ts +1 -0
  42. package/out/language-server/chat/telemetry/chatTelemetryController.js +11 -0
  43. package/out/language-server/chat/telemetry/chatTelemetryController.js.map +1 -1
  44. package/out/language-server/inline-completion/codeWhispererServer.d.ts +0 -1
  45. package/out/language-server/inline-completion/codeWhispererServer.js +14 -478
  46. package/out/language-server/inline-completion/codeWhispererServer.js.map +1 -1
  47. package/out/language-server/inline-completion/{editCompletionHandler.d.ts → handler/editCompletionHandler.d.ts} +10 -10
  48. package/out/language-server/inline-completion/{editCompletionHandler.js → handler/editCompletionHandler.js} +17 -14
  49. package/out/language-server/inline-completion/handler/editCompletionHandler.js.map +1 -0
  50. package/out/language-server/inline-completion/handler/inlineCompletionHandler.d.ts +32 -0
  51. package/out/language-server/inline-completion/handler/inlineCompletionHandler.js +377 -0
  52. package/out/language-server/inline-completion/handler/inlineCompletionHandler.js.map +1 -0
  53. package/out/language-server/inline-completion/handler/sessionResultsHandler.d.ts +23 -0
  54. package/out/language-server/inline-completion/handler/sessionResultsHandler.js +119 -0
  55. package/out/language-server/inline-completion/handler/sessionResultsHandler.js.map +1 -0
  56. package/out/language-server/inline-completion/telemetry/telemetry.js.map +1 -1
  57. package/out/language-server/inline-completion/utils/diffUtils.d.ts +28 -11
  58. package/out/language-server/inline-completion/utils/diffUtils.js +269 -117
  59. package/out/language-server/inline-completion/utils/diffUtils.js.map +1 -1
  60. package/out/language-server/inline-completion/utils/mergeRightUtils.d.ts +1 -9
  61. package/out/language-server/inline-completion/utils/mergeRightUtils.js +5 -33
  62. package/out/language-server/inline-completion/utils/mergeRightUtils.js.map +1 -1
  63. package/out/language-server/inline-completion/utils/textDocumentUtils.d.ts +3 -0
  64. package/out/language-server/inline-completion/utils/textDocumentUtils.js +37 -0
  65. package/out/language-server/inline-completion/utils/textDocumentUtils.js.map +1 -0
  66. package/out/language-server/inline-completion/{trigger.d.ts → utils/triggerUtils.d.ts} +4 -4
  67. package/out/language-server/inline-completion/{trigger.js → utils/triggerUtils.js} +3 -3
  68. package/out/language-server/inline-completion/utils/triggerUtils.js.map +1 -0
  69. package/out/language-server/workspaceContext/workspaceFolderManager.js +3 -1
  70. package/out/language-server/workspaceContext/workspaceFolderManager.js.map +1 -1
  71. package/out/shared/codeWhispererService.js +19 -18
  72. package/out/shared/codeWhispererService.js.map +1 -1
  73. package/out/shared/streamingClientService.d.ts +6 -1
  74. package/out/shared/streamingClientService.js +33 -12
  75. package/out/shared/streamingClientService.js.map +1 -1
  76. package/out/shared/telemetry/telemetryService.js.map +1 -1
  77. package/out/shared/telemetry/types.d.ts +8 -0
  78. package/out/shared/telemetry/types.js +1 -0
  79. package/out/shared/telemetry/types.js.map +1 -1
  80. package/out/shared/utils.d.ts +9 -3
  81. package/out/shared/utils.js +15 -10
  82. package/out/shared/utils.js.map +1 -1
  83. package/package.json +2 -2
  84. package/out/language-server/inline-completion/editCompletionHandler.js.map +0 -1
  85. package/out/language-server/inline-completion/trigger.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.0.84](https://github.com/aws/language-servers/compare/lsp-codewhisperer/v0.0.83...lsp-codewhisperer/v0.0.84) (2025-10-09)
4
+
5
+
6
+ ### Features
7
+
8
+ * add model description to dropdown ([#2374](https://github.com/aws/language-servers/issues/2374)) ([ed8c6dd](https://github.com/aws/language-servers/commit/ed8c6dda1312f728e9ee7472f7ca447196ad9d84))
9
+ * **amazonq:** adding classification based retry strategy for chat ([#2234](https://github.com/aws/language-servers/issues/2234)) ([#2409](https://github.com/aws/language-servers/issues/2409)) ([15d1b1f](https://github.com/aws/language-servers/commit/15d1b1f5947a1b83dab65c9d3fef901ab8a033c9))
10
+ * **amazonq:** env var change for JupyterLab conversation history on refresh support ([#2395](https://github.com/aws/language-servers/issues/2395)) ([a908195](https://github.com/aws/language-servers/commit/a9081954bcaf20b7d0fbe0af11e61b8f82c7e82f))
11
+ * **amazonq:** support JupyterLab conversation history on refresh ([#2325](https://github.com/aws/language-servers/issues/2325)) ([0980351](https://github.com/aws/language-servers/commit/09803514d1ce31ca77a532161e071e1d037e3fb1))
12
+
13
+
14
+ ### Bug Fixes
15
+
16
+ * add in-loop compaction ([#2387](https://github.com/aws/language-servers/issues/2387)) ([35f0795](https://github.com/aws/language-servers/commit/35f0795fa5d09f3610e6a29cb72d49f32cc5534e))
17
+ * addonly EDITS should be handled as COMPLETIONS ([#2133](https://github.com/aws/language-servers/issues/2133)) ([4f5a9da](https://github.com/aws/language-servers/commit/4f5a9dacf3bfd68aeb40920fb800adf001ed43d5))
18
+ * patch [#2133](https://github.com/aws/language-servers/issues/2133) and handle more variants of FIM suggestions ([#2407](https://github.com/aws/language-servers/issues/2407)) ([f3086d7](https://github.com/aws/language-servers/commit/f3086d71808bd49336e0df9ba30f5be5fda837c3))
19
+
3
20
  ## [0.0.83](https://github.com/aws/language-servers/compare/lsp-codewhisperer/v0.0.82...lsp-codewhisperer/v0.0.83) (2025-10-01)
4
21
 
5
22
 
@@ -469,9 +469,10 @@ class AgenticChatController {
469
469
  });
470
470
  // Wait for the response to be completed before proceeding
471
471
  this.#log('Model Response: ', JSON.stringify(responseResult, null, 2));
472
- models = Object.values(responseResult.models).map(({ modelId, modelName }) => ({
472
+ models = Object.values(responseResult.models).map(({ modelId, modelName, description }) => ({
473
473
  id: modelId,
474
474
  name: modelName ?? modelId,
475
+ description: description ?? '',
475
476
  }));
476
477
  defaultModelId = responseResult.defaultModel?.modelId;
477
478
  // Cache the models with defaultModelId
@@ -505,7 +506,7 @@ class AgenticChatController {
505
506
  // Get models from cache or API
506
507
  const { models, defaultModelId, errorFromAPI } = await this.#fetchModelsWithCache();
507
508
  // Get the first fallback model option as default
508
- const defaultModelOption = modelSelection_1.FALLBACK_MODEL_OPTIONS[1];
509
+ const defaultModelOption = modelSelection_1.FALLBACK_MODEL_OPTIONS[0];
509
510
  const DEFAULT_MODEL_ID = defaultModelId || defaultModelOption?.id;
510
511
  const sessionResult = this.#chatSessionManagementService.getSession(params.tabId);
511
512
  const { data: session, success } = sessionResult;
@@ -654,6 +655,11 @@ class AgenticChatController {
654
655
  }
655
656
  const compactIds = session.getAllDeferredCompactMessageIds();
656
657
  await this.#invalidateCompactCommand(params.tabId, compactIds);
658
+ // Set compactionDeclined flag if there were pending compaction requests
659
+ // This prevents endless compaction warning loops when user declines compaction once
660
+ if (compactIds.length > 0) {
661
+ session.compactionDeclined = true;
662
+ }
657
663
  session.rejectAllDeferredToolExecutions(new toolShared_1.ToolApprovalException('Command ignored: new prompt', false));
658
664
  await this.#invalidateAllShellCommands(params.tabId, session);
659
665
  const metric = new metric_1.Metric({
@@ -685,6 +691,10 @@ class AgenticChatController {
685
691
  session.abortRequest();
686
692
  const compactIds = session.getAllDeferredCompactMessageIds();
687
693
  await this.#invalidateCompactCommand(params.tabId, compactIds);
694
+ // Set compactionDeclined flag if there were pending compaction requests
695
+ if (compactIds.length > 0) {
696
+ session.compactionDeclined = true;
697
+ }
688
698
  void this.#invalidateAllShellCommands(params.tabId, session);
689
699
  session.rejectAllDeferredToolExecutions(new lsp_core_1.CancellationError('user'));
690
700
  // Then update UI to inform the user
@@ -698,6 +708,13 @@ class AgenticChatController {
698
708
  await this.#telemetryController.emitAddMessageMetric(params.tabId, metric.metric, 'Cancelled');
699
709
  });
700
710
  session.setConversationType('AgenticChat');
711
+ // Set up delay notification callback to show retry progress to users
712
+ session.setDelayNotificationCallback(notification => {
713
+ if (notification.thresholdExceeded) {
714
+ this.#log(`Updating progress message: ${notification.message}`);
715
+ void chatResultStream.updateProgressMessage(notification.message);
716
+ }
717
+ });
701
718
  const additionalContext = await this.#additionalContextProvider.getAdditionalContext(triggerContext, params.tabId, params.context, params.prompt.prompt);
702
719
  // Add active file to context list if it's not already there
703
720
  const activeFile = triggerContext.text &&
@@ -740,7 +757,12 @@ class AgenticChatController {
740
757
  finalResult = await this.#runAgentLoop(initialRequestInput, session, metric, chatResultStream, params.tabId, promptId, session.conversationId, token, triggerContext.documentReference, additionalContext);
741
758
  }
742
759
  // Result Handling - This happens only once
743
- return await this.#handleFinalResult(finalResult, session, params.tabId, metric, triggerContext, isNewConversation, chatResultStream);
760
+ const result = await this.#handleFinalResult(finalResult, session, params.tabId, metric, triggerContext, isNewConversation, chatResultStream);
761
+ // Reset compactionDeclined flag after successful completion
762
+ if (session.compactionDeclined) {
763
+ session.compactionDeclined = false;
764
+ }
765
+ return result;
744
766
  }
745
767
  catch (err) {
746
768
  // HACK: the chat-client needs to have a partial event with the associated messageId sent before it can accept the final result.
@@ -782,19 +804,20 @@ class AgenticChatController {
782
804
  /**
783
805
  * Prepares the initial request input for the chat prompt
784
806
  */
785
- #getCompactionRequestInput(session) {
807
+ #getCompactionRequestInput(session, toolResults) {
786
808
  this.#debug('Preparing compaction request input');
787
809
  // Get profileArn from the service manager if available
788
810
  const profileArn = this.#serviceManager?.getActiveProfileArn();
789
- const requestInput = this.#triggerContext.getCompactionChatCommandInput(profileArn, this.#getTools(session), session.modelId, this.#origin);
811
+ const requestInput = this.#triggerContext.getCompactionChatCommandInput(profileArn, this.#getTools(session), session.modelId, this.#origin, toolResults);
790
812
  return requestInput;
791
813
  }
792
814
  /**
793
815
  * Runs the compaction, making requests and processing tool uses until completion
794
816
  */
795
- #shouldCompact(currentRequestCount) {
796
- if (currentRequestCount > constants_2.COMPACTION_CHARACTER_THRESHOLD) {
797
- this.#debug(`Current request total character count is: ${currentRequestCount}, prompting user to compact`);
817
+ #shouldCompact(currentRequestCount, session) {
818
+ const EFFECTIVE_COMPACTION_THRESHOLD = constants_2.COMPACTION_CHARACTER_THRESHOLD - constants_2.COMPACTION_PROMPT.length;
819
+ if (currentRequestCount > EFFECTIVE_COMPACTION_THRESHOLD && !session.compactionDeclined) {
820
+ this.#debug(`Current request total character count is: ${currentRequestCount}, prompting user to compact (threshold: ${EFFECTIVE_COMPACTION_THRESHOLD})`);
798
821
  return true;
799
822
  }
800
823
  else {
@@ -914,6 +937,8 @@ class AgenticChatController {
914
937
  let shouldDisplayMessage = true;
915
938
  let currentRequestCount = 0;
916
939
  const pinnedContext = additionalContext?.filter(item => item.pinned);
940
+ // Store initial non-empty prompt for compaction handoff
941
+ const initialPrompt = initialRequestInput.conversationState?.currentMessage?.userInputMessage?.content?.trim() || '';
917
942
  metric.recordStart();
918
943
  this.logSystemInformation();
919
944
  while (true) {
@@ -963,6 +988,34 @@ class AgenticChatController {
963
988
  this.#llmRequestStartTime = Date.now();
964
989
  // Phase 3: Request Execution
965
990
  currentRequestInput = (0, utils_2.sanitizeRequestInput)(currentRequestInput);
991
+ if (this.#shouldCompact(currentRequestCount, session)) {
992
+ this.#features.logging.info(`Entering mid-loop compaction at iteration ${iterationCount} with ${currentRequestCount} characters`);
993
+ this.#telemetryController.emitMidLoopCompaction(currentRequestCount, iterationCount, this.#features.runtime.serverInfo.version ?? '');
994
+ const messageId = this.#getMessageIdForCompact((0, uuid_1.v4)());
995
+ const confirmationResult = this.#processCompactConfirmation(messageId, currentRequestCount);
996
+ const cachedButtonBlockId = await chatResultStream.writeResultBlock(confirmationResult);
997
+ await this.waitForCompactApproval(messageId, chatResultStream, cachedButtonBlockId, session);
998
+ // Run compaction
999
+ const toolResults = currentRequestInput.conversationState?.currentMessage?.userInputMessage?.userInputMessageContext
1000
+ ?.toolResults || [];
1001
+ const compactionRequestInput = this.#getCompactionRequestInput(session, toolResults);
1002
+ const compactionResult = await this.#runCompaction(compactionRequestInput, session, metric, chatResultStream, tabId, promptId, types_1.CompactHistoryActionType.Nudge, session.conversationId, token, documentReference);
1003
+ if (!compactionResult.success) {
1004
+ this.#features.logging.error(`Compaction failed: ${compactionResult.error}`);
1005
+ return compactionResult;
1006
+ }
1007
+ // Show compaction summary to user before continuing
1008
+ await chatResultStream.writeResultBlock({
1009
+ type: 'answer',
1010
+ body: (compactionResult.data?.chatResult.body || '') +
1011
+ '\n\nConversation history has been compacted successfully!',
1012
+ messageId: (0, uuid_1.v4)(),
1013
+ });
1014
+ currentRequestInput = this.#updateRequestInputWithToolResults(currentRequestInput, [], constants_2.MID_LOOP_COMPACTION_HANDOFF_PROMPT + initialPrompt);
1015
+ shouldDisplayMessage = false;
1016
+ this.#features.logging.info(`Completed mid-loop compaction, restarting loop with handoff prompt`);
1017
+ continue;
1018
+ }
966
1019
  // Note: these logs are very noisy, but contain information redacted on the backend.
967
1020
  this.#debug(`generateAssistantResponse/SendMessage Request: ${JSON.stringify(currentRequestInput, this.#imageReplacer, 2)}`);
968
1021
  const response = await session.getChatResponse(currentRequestInput);
@@ -1105,7 +1158,7 @@ class AgenticChatController {
1105
1158
  }
1106
1159
  currentRequestInput = this.#updateRequestInputWithToolResults(currentRequestInput, toolResults, content);
1107
1160
  }
1108
- if (this.#shouldCompact(currentRequestCount)) {
1161
+ if (this.#shouldCompact(currentRequestCount, session)) {
1109
1162
  this.#telemetryController.emitCompactNudge(currentRequestCount, this.#features.runtime.serverInfo.version ?? '');
1110
1163
  const messageId = this.#getMessageIdForCompact((0, uuid_1.v4)());
1111
1164
  const confirmationResult = this.#processCompactConfirmation(messageId, currentRequestCount);