@aws/lsp-codewhisperer 0.0.72 → 0.0.74

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 (97) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/out/client/token/bearer-token-service.json +85 -0
  3. package/out/language-server/agenticChat/agenticChatController.d.ts +14 -1
  4. package/out/language-server/agenticChat/agenticChatController.js +117 -74
  5. package/out/language-server/agenticChat/agenticChatController.js.map +1 -1
  6. package/out/language-server/agenticChat/agenticChatResultStream.d.ts +4 -27
  7. package/out/language-server/agenticChat/agenticChatResultStream.js +15 -31
  8. package/out/language-server/agenticChat/agenticChatResultStream.js.map +1 -1
  9. package/out/language-server/agenticChat/constants/constants.d.ts +2 -0
  10. package/out/language-server/agenticChat/constants/constants.js +3 -1
  11. package/out/language-server/agenticChat/constants/constants.js.map +1 -1
  12. package/out/language-server/agenticChat/context/additionalContextProvider.js +1 -1
  13. package/out/language-server/agenticChat/context/additionalContextProvider.js.map +1 -1
  14. package/out/language-server/agenticChat/qAgenticChatServer.js +1 -1
  15. package/out/language-server/agenticChat/qAgenticChatServer.js.map +1 -1
  16. package/out/language-server/agenticChat/tools/fileSearch.d.ts +1 -0
  17. package/out/language-server/agenticChat/tools/fileSearch.js +4 -0
  18. package/out/language-server/agenticChat/tools/fileSearch.js.map +1 -1
  19. package/out/language-server/agenticChat/tools/mcp/mcpEventHandler.d.ts +7 -0
  20. package/out/language-server/agenticChat/tools/mcp/mcpEventHandler.js +71 -40
  21. package/out/language-server/agenticChat/tools/mcp/mcpEventHandler.js.map +1 -1
  22. package/out/language-server/agenticChat/tools/mcp/mcpManager.d.ts +4 -0
  23. package/out/language-server/agenticChat/tools/mcp/mcpManager.js +65 -36
  24. package/out/language-server/agenticChat/tools/mcp/mcpManager.js.map +1 -1
  25. package/out/language-server/agenticChat/tools/mcp/mcpUtils.d.ts +1 -1
  26. package/out/language-server/agenticChat/tools/mcp/mcpUtils.js +5 -39
  27. package/out/language-server/agenticChat/tools/mcp/mcpUtils.js.map +1 -1
  28. package/out/language-server/agenticChat/tools/mcp/profileStatusMonitor.d.ts +34 -0
  29. package/out/language-server/agenticChat/tools/mcp/profileStatusMonitor.js +159 -0
  30. package/out/language-server/agenticChat/tools/mcp/profileStatusMonitor.js.map +1 -0
  31. package/out/language-server/agenticChat/tools/qCodeAnalysis/codeReview.js +5 -0
  32. package/out/language-server/agenticChat/tools/qCodeAnalysis/codeReview.js.map +1 -1
  33. package/out/language-server/agenticChat/tools/toolServer.js +123 -23
  34. package/out/language-server/agenticChat/tools/toolServer.js.map +1 -1
  35. package/out/language-server/chat/qChatServer.js +1 -1
  36. package/out/language-server/chat/qChatServer.js.map +1 -1
  37. package/out/language-server/inline-completion/codePercentage.d.ts +2 -0
  38. package/out/language-server/inline-completion/codePercentage.js +10 -2
  39. package/out/language-server/inline-completion/codePercentage.js.map +1 -1
  40. package/out/language-server/inline-completion/codeWhispererServer.d.ts +1 -0
  41. package/out/language-server/inline-completion/codeWhispererServer.js +119 -109
  42. package/out/language-server/inline-completion/codeWhispererServer.js.map +1 -1
  43. package/out/language-server/inline-completion/constants.d.ts +1 -1
  44. package/out/language-server/inline-completion/constants.js +26 -2
  45. package/out/language-server/inline-completion/constants.js.map +1 -1
  46. package/out/language-server/inline-completion/diffUtils.d.ts +15 -0
  47. package/out/language-server/inline-completion/diffUtils.js +53 -0
  48. package/out/language-server/inline-completion/diffUtils.js.map +1 -1
  49. package/out/language-server/inline-completion/editCompletionHandler.d.ts +3 -0
  50. package/out/language-server/inline-completion/editCompletionHandler.js +55 -76
  51. package/out/language-server/inline-completion/editCompletionHandler.js.map +1 -1
  52. package/out/language-server/inline-completion/session/sessionManager.d.ts +5 -5
  53. package/out/language-server/inline-completion/session/sessionManager.js +11 -8
  54. package/out/language-server/inline-completion/session/sessionManager.js.map +1 -1
  55. package/out/language-server/inline-completion/telemetry.d.ts +4 -3
  56. package/out/language-server/inline-completion/telemetry.js +20 -10
  57. package/out/language-server/inline-completion/telemetry.js.map +1 -1
  58. package/out/language-server/inline-completion/trigger.d.ts +2 -11
  59. package/out/language-server/inline-completion/trigger.js.map +1 -1
  60. package/out/language-server/netTransform/resources/SupportedProjects.d.ts +3 -0
  61. package/out/language-server/netTransform/resources/SupportedProjects.js +3 -0
  62. package/out/language-server/netTransform/resources/SupportedProjects.js.map +1 -1
  63. package/out/language-server/netTransform/transformHandler.js +0 -13
  64. package/out/language-server/netTransform/transformHandler.js.map +1 -1
  65. package/out/language-server/netTransform/validation.d.ts +1 -5
  66. package/out/language-server/netTransform/validation.js +1 -21
  67. package/out/language-server/netTransform/validation.js.map +1 -1
  68. package/out/language-server/workspaceContext/IdleWorkspaceManager.d.ts +14 -0
  69. package/out/language-server/workspaceContext/IdleWorkspaceManager.js +42 -0
  70. package/out/language-server/workspaceContext/IdleWorkspaceManager.js.map +1 -0
  71. package/out/language-server/workspaceContext/artifactManager.js +14 -0
  72. package/out/language-server/workspaceContext/artifactManager.js.map +1 -1
  73. package/out/language-server/workspaceContext/dependency/dependencyDiscoverer.d.ts +1 -1
  74. package/out/language-server/workspaceContext/dependency/dependencyDiscoverer.js +2 -1
  75. package/out/language-server/workspaceContext/dependency/dependencyDiscoverer.js.map +1 -1
  76. package/out/language-server/workspaceContext/workspaceContextServer.js +4 -7
  77. package/out/language-server/workspaceContext/workspaceContextServer.js.map +1 -1
  78. package/out/language-server/workspaceContext/workspaceFolderManager.d.ts +10 -5
  79. package/out/language-server/workspaceContext/workspaceFolderManager.js +140 -85
  80. package/out/language-server/workspaceContext/workspaceFolderManager.js.map +1 -1
  81. package/out/shared/amazonQServiceManager/AmazonQTokenServiceManager.js +13 -0
  82. package/out/shared/amazonQServiceManager/AmazonQTokenServiceManager.js.map +1 -1
  83. package/out/shared/amazonQServiceManager/BaseAmazonQServiceManager.d.ts +1 -0
  84. package/out/shared/amazonQServiceManager/BaseAmazonQServiceManager.js +3 -0
  85. package/out/shared/amazonQServiceManager/BaseAmazonQServiceManager.js.map +1 -1
  86. package/out/shared/codeWhispererService.d.ts +16 -9
  87. package/out/shared/codeWhispererService.js +55 -16
  88. package/out/shared/codeWhispererService.js.map +1 -1
  89. package/out/shared/telemetry/telemetryService.d.ts +2 -2
  90. package/out/shared/telemetry/telemetryService.js +5 -7
  91. package/out/shared/telemetry/telemetryService.js.map +1 -1
  92. package/out/shared/telemetryUtils.d.ts +1 -1
  93. package/out/shared/telemetryUtils.js +7 -3
  94. package/out/shared/telemetryUtils.js.map +1 -1
  95. package/out/shared/utils.js +4 -1
  96. package/out/shared/utils.js.map +1 -1
  97. package/package.json +3 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,60 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.0.74](https://github.com/aws/language-servers/compare/lsp-codewhisperer/v0.0.73...lsp-codewhisperer/v0.0.74) (2025-08-19)
4
+
5
+
6
+ ### Features
7
+
8
+ * **amazonq:** added mcp admin level configuration with GetProfile ([#2000](https://github.com/aws/language-servers/issues/2000)) ([fd6e9a8](https://github.com/aws/language-servers/commit/fd6e9a829c6229c276de5340dffce52b426a864d))
9
+ * **amazonq:** read tool ui revamp ([#2113](https://github.com/aws/language-servers/issues/2113)) ([#2121](https://github.com/aws/language-servers/issues/2121)) ([93cf229](https://github.com/aws/language-servers/commit/93cf229149ba60491f9f5763793db4a9f570b611))
10
+ * remove project type validation from LSP layer ([#2103](https://github.com/aws/language-servers/issues/2103)) ([d397161](https://github.com/aws/language-servers/commit/d397161cc3448c63016e27f5ac2a1917cdaae1cb))
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * **amazonq:** add server side control for WCS features ([#2128](https://github.com/aws/language-servers/issues/2128)) ([5e4435d](https://github.com/aws/language-servers/commit/5e4435dfaea7bf8c00e6a27b9bb0d40f699d4e01))
16
+ * **amazonq:** fix regression of mcp config in agent config ([#2101](https://github.com/aws/language-servers/issues/2101)) ([e4e8bbb](https://github.com/aws/language-servers/commit/e4e8bbb89e4b597926582bead2b14ffc43f2a7f8))
17
+ * **amazonq:** handle case where multiple rules are provided with the same name ([#2118](https://github.com/aws/language-servers/issues/2118)) ([0e23e2d](https://github.com/aws/language-servers/commit/0e23e2d29b8cad14403d372b9bbb08ca8ffa7ac7))
18
+ * **amazonq:** persist mcp configs in agent json on start-up ([#2112](https://github.com/aws/language-servers/issues/2112)) ([817cfe2](https://github.com/aws/language-servers/commit/817cfe2656cb1deec6111c699c4ba46b4ba53e00))
19
+ * empty userTriggerDecision not being sent for NEP code path ([#2140](https://github.com/aws/language-servers/issues/2140)) ([b8e5268](https://github.com/aws/language-servers/commit/b8e52682ac2b2337e1d0a32759e8beccde889cee))
20
+ * fix for button text and remove profilearn caching ([#2137](https://github.com/aws/language-servers/issues/2137)) ([2a4171a](https://github.com/aws/language-servers/commit/2a4171a74c15c23c23c481060496162bcc9e6284))
21
+ * fix to add disk caching for mcp admin state ([#2139](https://github.com/aws/language-servers/issues/2139)) ([f947e1a](https://github.com/aws/language-servers/commit/f947e1a9da4431d6089b22825f992010c30a470b))
22
+ * fix to turn on and off MCP servers incase of error based on last state ([#2143](https://github.com/aws/language-servers/issues/2143)) ([04588df](https://github.com/aws/language-servers/commit/04588dfc33f0d85dbd488814a474b5e354398df0))
23
+ * proper path handling for additional context ([#2129](https://github.com/aws/language-servers/issues/2129)) ([971eaa5](https://github.com/aws/language-servers/commit/971eaa505d948e9d2090c85f9b965f554ea7f2c8))
24
+ * Use file context override in the inline completion params for Jupyter Notebook ([#2114](https://github.com/aws/language-servers/issues/2114)) ([91c8398](https://github.com/aws/language-servers/commit/91c839857f8aa4d79098189f9fb620b361c51289))
25
+
26
+
27
+ ### Performance Improvements
28
+
29
+ * remove edit completion retry mechanism on document change ([#2124](https://github.com/aws/language-servers/issues/2124)) ([963b6e9](https://github.com/aws/language-servers/commit/963b6e9b7887da23a85a826c55a6ed95ff36d956))
30
+
31
+
32
+ ### Dependencies
33
+
34
+ * The following workspace dependencies were updated
35
+ * dependencies
36
+ * @aws/lsp-core bumped from ^0.0.13 to ^0.0.14
37
+
38
+ ## [0.0.73](https://github.com/aws/language-servers/compare/lsp-codewhisperer/v0.0.72...lsp-codewhisperer/v0.0.73) (2025-08-11)
39
+
40
+
41
+ ### Features
42
+
43
+ * **amazonq:** read tool ui revamp ([c65428b](https://github.com/aws/language-servers/commit/c65428bab2cf5e47badf1e3a9453babcf881e60c))
44
+
45
+
46
+ ### Bug Fixes
47
+
48
+ * **amazonq:** add fallback classpath generation ([#2077](https://github.com/aws/language-servers/issues/2077)) ([3a6ef14](https://github.com/aws/language-servers/commit/3a6ef14e78fa2e75b837bba6524751d65038f416))
49
+ * **amazonq:** emit failed status for amazonq_invokeLLM ([#2071](https://github.com/aws/language-servers/issues/2071)) ([ee52a41](https://github.com/aws/language-servers/commit/ee52a41bc869b275fff708d7955b59f43b93bbd4))
50
+ * **amazonq:** fix fallout of [#2051](https://github.com/aws/language-servers/issues/2051) ([#2057](https://github.com/aws/language-servers/issues/2057)) ([565066b](https://github.com/aws/language-servers/commit/565066bb61adda60333c9646db958d4208bcc8af))
51
+ * **amazonq:** leverage lcs to find the chars added and removed ([#2092](https://github.com/aws/language-servers/issues/2092)) ([40379a8](https://github.com/aws/language-servers/commit/40379a887f8d42cc184239ca3175b4e673cc5286))
52
+ * **amazonq:** skips continuous monitoring when WCS sees workspace as idle ([#2066](https://github.com/aws/language-servers/issues/2066)) ([9cb959d](https://github.com/aws/language-servers/commit/9cb959d4cc450d0907f8bf5265ba01d2aa68bcd0))
53
+ * creating a new sesion for Edits trigger with next token ([#2094](https://github.com/aws/language-servers/issues/2094)) ([1da8730](https://github.com/aws/language-servers/commit/1da8730b6ed6ad53b6561368bf722e56d59596a4))
54
+ * remove edit cache logic ([#2079](https://github.com/aws/language-servers/issues/2079)) ([9bc5b9c](https://github.com/aws/language-servers/commit/9bc5b9c1d77e5fee6f518f7f5016d3a0043a5a77))
55
+ * sessionManager misused because there are 2 types of manager now ([#2090](https://github.com/aws/language-servers/issues/2090)) ([8db059a](https://github.com/aws/language-servers/commit/8db059ab83d94fd7c3ba3eb265044add31c80aea))
56
+ * update client name to support Sagemaker AI origin for agentic chat ([#2093](https://github.com/aws/language-servers/issues/2093)) ([a746fe8](https://github.com/aws/language-servers/commit/a746fe845d5e09563b475f01ce44059dca9fd10f))
57
+
3
58
  ## [0.0.72](https://github.com/aws/language-servers/compare/lsp-codewhisperer/v0.0.71...lsp-codewhisperer/v0.0.72) (2025-08-06)
4
59
 
5
60
 
@@ -516,6 +516,37 @@
516
516
  ],
517
517
  "documentation": "<p>API to get code transformation status.</p>"
518
518
  },
519
+ "GetProfile": {
520
+ "name": "GetProfile",
521
+ "http": {
522
+ "method": "POST",
523
+ "requestUri": "/"
524
+ },
525
+ "input": {
526
+ "shape": "GetProfileRequest"
527
+ },
528
+ "output": {
529
+ "shape": "GetProfileResponse"
530
+ },
531
+ "errors": [
532
+ {
533
+ "shape": "ThrottlingException"
534
+ },
535
+ {
536
+ "shape": "ResourceNotFoundException"
537
+ },
538
+ {
539
+ "shape": "InternalServerException"
540
+ },
541
+ {
542
+ "shape": "ValidationException"
543
+ },
544
+ {
545
+ "shape": "AccessDeniedException"
546
+ }
547
+ ],
548
+ "documentation": "<p>Get the requested CodeWhisperer profile.</p>"
549
+ },
519
550
  "GetUsageLimits": {
520
551
  "name": "GetUsageLimits",
521
552
  "http": {
@@ -3126,6 +3157,24 @@
3126
3157
  }
3127
3158
  }
3128
3159
  },
3160
+ "GetProfileRequest": {
3161
+ "type": "structure",
3162
+ "required": ["profileArn"],
3163
+ "members": {
3164
+ "profileArn": {
3165
+ "shape": "ProfileArn"
3166
+ }
3167
+ }
3168
+ },
3169
+ "GetProfileResponse": {
3170
+ "type": "structure",
3171
+ "required": ["profile"],
3172
+ "members": {
3173
+ "profile": {
3174
+ "shape": "ProfileInfo"
3175
+ }
3176
+ }
3177
+ },
3129
3178
  "GetTaskAssistCodeGenerationRequest": {
3130
3179
  "type": "structure",
3131
3180
  "required": ["conversationId", "codeGenerationId"],
@@ -3787,6 +3836,15 @@
3787
3836
  "type": "long",
3788
3837
  "box": true
3789
3838
  },
3839
+ "MCPConfiguration": {
3840
+ "type": "structure",
3841
+ "required": ["toggle"],
3842
+ "members": {
3843
+ "toggle": {
3844
+ "shape": "OptInFeatureToggle"
3845
+ }
3846
+ }
3847
+ },
3790
3848
  "MemoryEntry": {
3791
3849
  "type": "structure",
3792
3850
  "required": ["id", "memoryEntryString", "metadata"],
@@ -3995,6 +4053,9 @@
3995
4053
  },
3996
4054
  "workspaceContext": {
3997
4055
  "shape": "WorkspaceContext"
4056
+ },
4057
+ "mcpConfiguration": {
4058
+ "shape": "MCPConfiguration"
3998
4059
  }
3999
4060
  }
4000
4061
  },
@@ -4189,6 +4250,30 @@
4189
4250
  }
4190
4251
  }
4191
4252
  },
4253
+ "ProfileInfo": {
4254
+ "type": "structure",
4255
+ "required": ["arn"],
4256
+ "members": {
4257
+ "arn": {
4258
+ "shape": "ProfileArn"
4259
+ },
4260
+ "profileName": {
4261
+ "shape": "ProfileName"
4262
+ },
4263
+ "description": {
4264
+ "shape": "ProfileDescription"
4265
+ },
4266
+ "status": {
4267
+ "shape": "ProfileStatus"
4268
+ },
4269
+ "profileType": {
4270
+ "shape": "ProfileType"
4271
+ },
4272
+ "optInFeatures": {
4273
+ "shape": "OptInFeatures"
4274
+ }
4275
+ }
4276
+ },
4192
4277
  "ProfileArn": {
4193
4278
  "type": "string",
4194
4279
  "max": 950,
@@ -2,7 +2,7 @@
2
2
  * Copied from ../chat/chatController.ts for the purpose of developing a divergent implementation.
3
3
  * Will be deleted or merged.
4
4
  */
5
- import { ToolUse } from '@amzn/codewhisperer-streaming';
5
+ import { ToolResult, ToolUse } from '@amzn/codewhisperer-streaming';
6
6
  import { ChatCommandInput } from '../../shared/streamingClientService';
7
7
  import { Status, ButtonClickParams, ButtonClickResult, InlineChatResultParams, PromptInputOptionChangeParams, RuleClickParams, ListRulesParams, ActiveEditorChangedParams, PinnedContextParams, ExecuteCommandParams, FollowUpClickParams, ListAvailableModelsParams, ListAvailableModelsResult, OpenFileDialogParams, OpenFileDialogResult } from '@aws/language-server-runtimes/protocol';
8
8
  import { FeedbackParams, InsertToCursorPositionParams, InlineChatParams, ConversationClickParams, ListConversationsParams, ListMcpServersParams, McpServerClickParams, TabBarActionParams, CreatePromptParams, FileClickParams } from '@aws/language-server-runtimes/protocol';
@@ -43,6 +43,13 @@ export declare class AgenticChatController implements ChatHandlers {
43
43
  icon: string;
44
44
  status: Status;
45
45
  } | undefined;
46
+ actions: {
47
+ id: string;
48
+ icon: string;
49
+ status: string;
50
+ text: string;
51
+ description: string;
52
+ }[];
46
53
  };
47
54
  list: import("@aws/language-server-runtimes/protocol").DetailedListGroup[];
48
55
  }>;
@@ -65,6 +72,12 @@ export declare class AgenticChatController implements ChatHandlers {
65
72
  * @param session
66
73
  */
67
74
  waitForToolApproval(toolUse: ToolUse, resultStream: AgenticChatResultStream, promptBlockId: number, session: ChatSessionService, toolName: string): Promise<void>;
75
+ /**
76
+ * Processes tool uses by running the tools and collecting results
77
+ */
78
+ processToolUses(toolUses: Array<ToolUse & {
79
+ stop: boolean;
80
+ }>, chatResultStream: AgenticChatResultStream, session: ChatSessionService, tabId: string, token?: CancellationToken, additionalContext?: AdditionalContentEntryAddition[]): Promise<ToolResult[]>;
68
81
  /**
69
82
  * Determines if error is thrown as a result of a user action (Ex. rejecting tool, stop button)
70
83
  * @param err
@@ -65,6 +65,7 @@ const path_1 = require("@aws/lsp-core/out/util/path");
65
65
  const agenticChatControllerHelper_1 = require("./utils/agenticChatControllerHelper");
66
66
  const activeUserTracker_1 = require("../../shared/activeUserTracker");
67
67
  const displayFindings_1 = require("./tools/qCodeAnalysis/displayFindings");
68
+ const IdleWorkspaceManager_1 = require("../workspaceContext/IdleWorkspaceManager");
68
69
  class AgenticChatController {
69
70
  #features;
70
71
  #chatSessionManagementService;
@@ -465,6 +466,7 @@ class AgenticChatController {
465
466
  async onChatPrompt(params, token) {
466
467
  // Phase 1: Initial Setup - This happens only once
467
468
  params.prompt.prompt = (0, utils_2.sanitizeInput)(params.prompt.prompt || '');
469
+ IdleWorkspaceManager_1.IdleWorkspaceManager.recordActivityTimestamp();
468
470
  const maybeDefaultResponse = !params.prompt.command && (0, utils_1.getDefaultChatResponse)(params.prompt.prompt);
469
471
  if (maybeDefaultResponse) {
470
472
  return maybeDefaultResponse;
@@ -844,6 +846,8 @@ class AgenticChatController {
844
846
  shouldDisplayMessage = false;
845
847
  // set the in progress tool use UI status to Error
846
848
  await chatResultStream.updateOngoingProgressResult('Error');
849
+ // emit invokeLLM event with status Failed for timeout calls
850
+ this.#telemetryController.emitAgencticLoop_InvokeLLM(response.$metadata.requestId, conversationId, 'AgenticChat', undefined, undefined, 'Failed', this.#features.runtime.serverInfo.version ?? '', session.modelId, llmLatency, this.#toolCallLatencies, this.#timeToFirstChunk, this.#timeBetweenChunks, session.pairProgrammingMode, this.#abTestingAllocation?.experimentName, this.#abTestingAllocation?.userVariation);
847
851
  continue;
848
852
  }
849
853
  // Add the current assistantResponse message to the history DB
@@ -881,7 +885,7 @@ class AgenticChatController {
881
885
  if (pendingToolUses.length === 0) {
882
886
  this.recordChunk('agent_loop_done');
883
887
  // No more tool uses, we're done
884
- this.#telemetryController.emitAgencticLoop_InvokeLLM(response.$metadata.requestId, conversationId, 'AgenticChat', undefined, undefined, 'Succeeded', this.#features.runtime.serverInfo.version ?? '', session.modelId, llmLatency, this.#toolCallLatencies, this.#timeToFirstChunk, this.#timeBetweenChunks, session.pairProgrammingMode, this.#abTestingAllocation?.experimentName, this.#abTestingAllocation?.userVariation);
888
+ this.#telemetryController.emitAgencticLoop_InvokeLLM(response.$metadata.requestId, conversationId, 'AgenticChat', undefined, undefined, result.success ? 'Succeeded' : 'Failed', this.#features.runtime.serverInfo.version ?? '', session.modelId, llmLatency, this.#toolCallLatencies, this.#timeToFirstChunk, this.#timeBetweenChunks, session.pairProgrammingMode, this.#abTestingAllocation?.experimentName, this.#abTestingAllocation?.userVariation);
885
889
  finalResult = result;
886
890
  break;
887
891
  }
@@ -890,7 +894,7 @@ class AgenticChatController {
890
894
  session.setConversationType('AgenticChatWithToolUse');
891
895
  if (result.success) {
892
896
  // Process tool uses and update the request input for the next iteration
893
- toolResults = await this.#processToolUses(pendingToolUses, chatResultStream, session, tabId, token);
897
+ toolResults = await this.processToolUses(pendingToolUses, chatResultStream, session, tabId, token, additionalContext);
894
898
  if (toolResults.some(toolResult => this.#shouldSendBackErrorContent(toolResult))) {
895
899
  content = 'There was an error processing one or more tool uses. Try again, do not apologize.';
896
900
  shouldDisplayMessage = false;
@@ -1090,7 +1094,7 @@ class AgenticChatController {
1090
1094
  /**
1091
1095
  * Processes tool uses by running the tools and collecting results
1092
1096
  */
1093
- async #processToolUses(toolUses, chatResultStream, session, tabId, token) {
1097
+ async processToolUses(toolUses, chatResultStream, session, tabId, token, additionalContext) {
1094
1098
  const results = [];
1095
1099
  for (const toolUse of toolUses) {
1096
1100
  // Store buttonBlockId to use it in `catch` block if needed
@@ -1112,8 +1116,7 @@ class AgenticChatController {
1112
1116
  this.#toolStartTime = Date.now();
1113
1117
  // remove progress UI
1114
1118
  await chatResultStream.removeResultBlockAndUpdateUI(agenticChatResultStream_1.progressPrefix + toolUse.toolUseId);
1115
- // fsRead and listDirectory write to an existing card and could show nothing in the current position
1116
- if (![toolConstants_1.FS_WRITE, toolConstants_1.FS_REPLACE, toolConstants_1.FS_READ, toolConstants_1.LIST_DIRECTORY].includes(toolUse.name)) {
1119
+ if (![toolConstants_1.FS_WRITE, toolConstants_1.FS_REPLACE].includes(toolUse.name)) {
1117
1120
  await this.#showUndoAllIfRequired(chatResultStream, session);
1118
1121
  }
1119
1122
  // fsWrite can take a long time, so we render fsWrite Explanatory upon partial streaming responses.
@@ -1229,12 +1232,10 @@ class AgenticChatController {
1229
1232
  if (toolUse.name === codeReview_1.CodeReview.toolName) {
1230
1233
  try {
1231
1234
  let initialInput = JSON.parse(JSON.stringify(toolUse.input));
1232
- let ruleArtifacts = await this.#additionalContextProvider.collectWorkspaceRules(tabId);
1233
- if (ruleArtifacts !== undefined || ruleArtifacts !== null) {
1234
- this.#features.logging.info(`RuleArtifacts: ${JSON.stringify(ruleArtifacts)}`);
1235
- let pathsToRulesMap = ruleArtifacts.map(ruleArtifact => ({ path: ruleArtifact.id }));
1236
- this.#features.logging.info(`PathsToRules: ${JSON.stringify(pathsToRulesMap)}`);
1237
- initialInput['ruleArtifacts'] = pathsToRulesMap;
1235
+ if (additionalContext !== undefined) {
1236
+ initialInput['ruleArtifacts'] = additionalContext
1237
+ .filter(c => c.type === 'rule')
1238
+ .map(c => ({ path: c.path }));
1238
1239
  }
1239
1240
  toolUse.input = initialInput;
1240
1241
  }
@@ -1270,10 +1271,14 @@ class AgenticChatController {
1270
1271
  switch (toolUse.name) {
1271
1272
  case toolConstants_1.FS_READ:
1272
1273
  case toolConstants_1.LIST_DIRECTORY:
1274
+ const readToolResult = await this.#processReadTool(toolUse, chatResultStream);
1275
+ if (readToolResult) {
1276
+ await chatResultStream.writeResultBlock(readToolResult);
1277
+ }
1278
+ break;
1273
1279
  case toolConstants_1.FILE_SEARCH:
1274
- const initialListDirResult = this.#processReadOrListOrSearch(toolUse, chatResultStream);
1275
- if (initialListDirResult) {
1276
- await chatResultStream.writeResultBlock(initialListDirResult);
1280
+ if ((0, fileSearch_1.isFileSearchParams)(toolUse.input)) {
1281
+ await this.#processFileSearchTool(toolUse.input, toolUse.toolUseId, result, chatResultStream);
1277
1282
  }
1278
1283
  break;
1279
1284
  // no need to write tool result for listDir,fsRead,fileSearch into chat stream
@@ -1617,7 +1622,6 @@ class AgenticChatController {
1617
1622
  return;
1618
1623
  }
1619
1624
  const toolMsgId = toolUse.toolUseId;
1620
- const chatMsgId = chatResultStream.getResult().messageId;
1621
1625
  let headerEmitted = false;
1622
1626
  const initialHeader = {
1623
1627
  body: 'shell',
@@ -1649,12 +1653,6 @@ class AgenticChatController {
1649
1653
  body: '```',
1650
1654
  header: completedHeader,
1651
1655
  });
1652
- await chatResultStream.writeResultBlock({
1653
- type: 'answer',
1654
- messageId: chatMsgId,
1655
- body: '',
1656
- header: undefined,
1657
- });
1658
1656
  this.#stoppedToolUses.add(toolMsgId);
1659
1657
  },
1660
1658
  });
@@ -2085,72 +2083,123 @@ class AgenticChatController {
2085
2083
  },
2086
2084
  };
2087
2085
  }
2088
- #processReadOrListOrSearch(toolUse, chatResultStream) {
2089
- let messageIdToUpdate = toolUse.toolUseId;
2090
- const currentId = chatResultStream.getMessageIdToUpdateForTool(toolUse.name);
2091
- if (currentId) {
2092
- messageIdToUpdate = currentId;
2093
- }
2094
- else {
2095
- chatResultStream.setMessageIdToUpdateForTool(toolUse.name, messageIdToUpdate);
2096
- }
2086
+ async #processFileSearchTool(toolInput, toolUseId, result, chatResultStream) {
2087
+ if (typeof result.output.content !== 'string')
2088
+ return;
2089
+ const { queryName, path: inputPath } = toolInput;
2090
+ const resultCount = result.output.content
2091
+ .split('\n')
2092
+ .filter(line => line.trim().startsWith('[F]') || line.trim().startsWith('[D]')).length;
2093
+ const chatMessage = {
2094
+ type: 'tool',
2095
+ messageId: toolUseId,
2096
+ header: {
2097
+ body: `Searched for "${queryName}" in `,
2098
+ icon: 'search',
2099
+ status: {
2100
+ text: `${resultCount} result${resultCount !== 1 ? 's' : ''} found`,
2101
+ },
2102
+ fileList: {
2103
+ filePaths: [inputPath],
2104
+ details: {
2105
+ [inputPath]: {
2106
+ description: inputPath,
2107
+ visibleName: path.basename(inputPath),
2108
+ clickable: false,
2109
+ },
2110
+ },
2111
+ },
2112
+ },
2113
+ };
2114
+ await chatResultStream.writeResultBlock(chatMessage);
2115
+ }
2116
+ async #processReadTool(toolUse, chatResultStream) {
2097
2117
  let currentPaths = [];
2098
2118
  if (toolUse.name === toolConstants_1.FS_READ) {
2099
- currentPaths = toolUse.input?.paths;
2119
+ currentPaths = toolUse.input?.paths || [];
2100
2120
  }
2101
- else {
2102
- currentPaths.push(toolUse.input?.path);
2121
+ else if (toolUse.name === toolConstants_1.LIST_DIRECTORY) {
2122
+ const singlePath = toolUse.input?.path;
2123
+ if (singlePath) {
2124
+ currentPaths = [singlePath];
2125
+ }
2103
2126
  }
2104
- if (!currentPaths)
2105
- return;
2106
- for (const currentPath of currentPaths) {
2107
- const existingPaths = chatResultStream.getMessageOperation(messageIdToUpdate)?.filePaths || [];
2108
- // Check if path already exists in the list
2109
- const isPathAlreadyProcessed = existingPaths.some(path => path.relativeFilePath === currentPath);
2110
- if (!isPathAlreadyProcessed) {
2111
- const currentFileDetail = {
2112
- relativeFilePath: currentPath,
2113
- lineRanges: [{ first: -1, second: -1 }],
2114
- };
2115
- chatResultStream.addMessageOperation(messageIdToUpdate, toolUse.name, [
2116
- ...existingPaths,
2117
- currentFileDetail,
2118
- ]);
2127
+ else if (toolUse.name === toolConstants_1.FILE_SEARCH) {
2128
+ const queryName = toolUse.input?.queryName;
2129
+ if (queryName) {
2130
+ currentPaths = [queryName];
2119
2131
  }
2120
2132
  }
2133
+ else {
2134
+ return;
2135
+ }
2136
+ if (currentPaths.length === 0)
2137
+ return;
2138
+ // Check if the last message is the same tool type
2139
+ const lastMessage = chatResultStream.getLastMessage();
2140
+ const isSameToolType = lastMessage?.type === 'tool' && lastMessage.header?.icon === this.#toolToIcon(toolUse.name);
2141
+ let allPaths = currentPaths;
2142
+ if (isSameToolType && lastMessage.messageId) {
2143
+ // Combine with existing paths and overwrite the last message
2144
+ const existingPaths = lastMessage.header?.fileList?.filePaths || [];
2145
+ allPaths = [...existingPaths, ...currentPaths];
2146
+ const blockId = chatResultStream.getMessageBlockId(lastMessage.messageId);
2147
+ if (blockId !== undefined) {
2148
+ // Create the updated message with combined paths
2149
+ const updatedMessage = this.#createFileListToolMessage(toolUse, allPaths, lastMessage.messageId);
2150
+ // Overwrite the existing block
2151
+ await chatResultStream.overwriteResultBlock(updatedMessage, blockId);
2152
+ return undefined; // Don't return a message since we already wrote it
2153
+ }
2154
+ }
2155
+ // Create new message with current paths
2156
+ return this.#createFileListToolMessage(toolUse, allPaths, toolUse.toolUseId);
2157
+ }
2158
+ #createFileListToolMessage(toolUse, filePaths, messageId) {
2159
+ const itemCount = filePaths.length;
2121
2160
  let title;
2122
- const itemCount = chatResultStream.getMessageOperation(messageIdToUpdate)?.filePaths.length;
2123
- const filePathsPushed = chatResultStream.getMessageOperation(messageIdToUpdate)?.filePaths ?? [];
2124
- if (!itemCount) {
2161
+ if (itemCount === 0) {
2125
2162
  title = 'Gathering context';
2126
2163
  }
2127
2164
  else {
2128
2165
  title =
2129
2166
  toolUse.name === toolConstants_1.FS_READ
2130
2167
  ? `${itemCount} file${itemCount > 1 ? 's' : ''} read`
2131
- : toolUse.name === toolConstants_1.FILE_SEARCH
2132
- ? `${itemCount} ${itemCount === 1 ? 'directory' : 'directories'} searched`
2133
- : `${itemCount} ${itemCount === 1 ? 'directory' : 'directories'} listed`;
2168
+ : toolUse.name === toolConstants_1.LIST_DIRECTORY
2169
+ ? `${itemCount} ${itemCount === 1 ? 'directory' : 'directories'} listed`
2170
+ : '';
2134
2171
  }
2135
2172
  const details = {};
2136
- for (const item of filePathsPushed) {
2137
- details[item.relativeFilePath] = {
2138
- lineRanges: item.lineRanges,
2139
- description: item.relativeFilePath,
2173
+ for (const filePath of filePaths) {
2174
+ details[filePath] = {
2175
+ description: filePath,
2176
+ visibleName: path.basename(filePath),
2177
+ clickable: toolUse.name === toolConstants_1.FS_READ,
2140
2178
  };
2141
2179
  }
2142
- const fileList = {
2143
- rootFolderTitle: title,
2144
- filePaths: filePathsPushed.map(item => item.relativeFilePath),
2145
- details,
2146
- };
2147
2180
  return {
2148
2181
  type: 'tool',
2149
- fileList,
2150
- messageId: messageIdToUpdate,
2151
- body: '',
2182
+ header: {
2183
+ body: title,
2184
+ icon: this.#toolToIcon(toolUse.name),
2185
+ fileList: {
2186
+ filePaths,
2187
+ details,
2188
+ },
2189
+ },
2190
+ messageId,
2152
2191
  };
2153
2192
  }
2193
+ #toolToIcon(toolName) {
2194
+ switch (toolName) {
2195
+ case toolConstants_1.FS_READ:
2196
+ return 'eye';
2197
+ case toolConstants_1.LIST_DIRECTORY:
2198
+ return 'check-list';
2199
+ default:
2200
+ return undefined;
2201
+ }
2202
+ }
2154
2203
  /**
2155
2204
  * Process grep search results and format them for display in the chat UI
2156
2205
  */
@@ -2158,14 +2207,7 @@ class AgenticChatController {
2158
2207
  if (toolUse.name !== toolConstants_1.GREP_SEARCH) {
2159
2208
  return undefined;
2160
2209
  }
2161
- let messageIdToUpdate = toolUse.toolUseId;
2162
- const currentId = chatResultStream.getMessageIdToUpdateForTool(toolUse.name);
2163
- if (currentId) {
2164
- messageIdToUpdate = currentId;
2165
- }
2166
- else {
2167
- chatResultStream.setMessageIdToUpdateForTool(toolUse.name, messageIdToUpdate);
2168
- }
2210
+ const messageIdToUpdate = toolUse.toolUseId;
2169
2211
  // Extract search results from the tool output
2170
2212
  const output = result.output.content;
2171
2213
  if (!output || !output.fileMatches || !Array.isArray(output.fileMatches)) {
@@ -2414,6 +2456,7 @@ class AgenticChatController {
2414
2456
  const metric = new metric_1.Metric({
2415
2457
  cwsprChatConversationType: 'Chat',
2416
2458
  });
2459
+ IdleWorkspaceManager_1.IdleWorkspaceManager.recordActivityTimestamp();
2417
2460
  const triggerContext = await this.#getInlineChatTriggerContext(params);
2418
2461
  let response;
2419
2462
  let requestInput;