4
4
*/
5
5
import {
6
6
ChatMessage ,
7
+ Tool ,
7
8
ToolResult ,
8
9
ToolResultStatus ,
9
10
UserInputMessage ,
10
11
UserInputMessageContext ,
11
12
} from '@amzn/codewhisperer-streaming'
12
13
import { randomUUID } from '../../shared/crypto'
13
14
import { getLogger } from '../../shared/logger/logger'
14
- import { tools , noWriteTools } from '../constants'
15
- import { ChatSessionStorage } from './chatSession'
15
+ import { tools } from '../constants'
16
16
17
17
// Maximum number of messages to keep in history
18
18
const MaxConversationHistoryLength = 100
@@ -27,12 +27,12 @@ export class ChatHistoryManager {
27
27
private history : ChatMessage [ ] = [ ]
28
28
private logger = getLogger ( )
29
29
private lastUserMessage ?: ChatMessage
30
- private sessionStorage : ChatSessionStorage
30
+ private tools : Tool [ ] = [ ]
31
31
32
32
constructor ( tabId ?: string ) {
33
33
this . conversationId = randomUUID ( )
34
34
this . tabId = tabId ?? randomUUID ( )
35
- this . sessionStorage = new ChatSessionStorage ( )
35
+ this . tools = tools
36
36
}
37
37
38
38
/**
@@ -178,14 +178,11 @@ export class ChatHistoryManager {
178
178
status : ToolResultStatus . ERROR ,
179
179
} ) )
180
180
181
- const session = this . sessionStorage . getSession ( this . tabId )
182
- const availableTools = session . pairProgrammingModeOn ? tools : noWriteTools
183
-
184
181
newUserMessage . userInputMessage . userInputMessageContext = {
185
182
shellState : undefined ,
186
183
envState : undefined ,
187
184
toolResults : toolResults ,
188
- tools : availableTools . length === 0 ? undefined : [ ...availableTools ] ,
185
+ tools : this . tools . length === 0 ? undefined : [ ...this . tools ] ,
189
186
}
190
187
191
188
return newUserMessage
@@ -202,14 +199,11 @@ export class ChatHistoryManager {
202
199
* Adds tool results to the conversation.
203
200
*/
204
201
addToolResults ( toolResults : ToolResult [ ] ) : void {
205
- const session = this . sessionStorage . getSession ( this . tabId )
206
- const availableTools = session . pairProgrammingModeOn ? tools : noWriteTools
207
-
208
202
const userInputMessageContext : UserInputMessageContext = {
209
203
shellState : undefined ,
210
204
envState : undefined ,
211
205
toolResults : toolResults ,
212
- tools : availableTools . length === 0 ? undefined : [ ...availableTools ] ,
206
+ tools : this . tools . length === 0 ? undefined : [ ...this . tools ] ,
213
207
}
214
208
215
209
const msg : UserInputMessage = {
@@ -254,15 +248,12 @@ export class ChatHistoryManager {
254
248
status : ToolResultStatus . ERROR ,
255
249
} ) )
256
250
257
- const session = this . sessionStorage . getSession ( this . tabId )
258
- const availableTools = session . pairProgrammingModeOn ? tools : noWriteTools
259
-
260
251
// Create a new user message with cancelled tool results
261
252
const userInputMessageContext : UserInputMessageContext = {
262
253
shellState : undefined ,
263
254
envState : undefined ,
264
255
toolResults : toolResults ,
265
- tools : availableTools . length === 0 ? undefined : [ ...availableTools ] ,
256
+ tools : this . tools . length === 0 ? undefined : [ ...this . tools ] ,
266
257
}
267
258
268
259
const userMessage : ChatMessage = {
0 commit comments