44 */
55import {
66 ChatMessage ,
7+ Tool ,
78 ToolResult ,
89 ToolResultStatus ,
910 UserInputMessage ,
1011 UserInputMessageContext ,
1112} from '@amzn/codewhisperer-streaming'
1213import { randomUUID } from '../../shared/crypto'
1314import { getLogger } from '../../shared/logger/logger'
14- import { tools , noWriteTools } from '../constants'
15- import { ChatSessionStorage } from './chatSession'
15+ import { tools } from '../constants'
1616
1717// Maximum number of messages to keep in history
1818const MaxConversationHistoryLength = 100
@@ -27,12 +27,12 @@ export class ChatHistoryManager {
2727 private history : ChatMessage [ ] = [ ]
2828 private logger = getLogger ( )
2929 private lastUserMessage ?: ChatMessage
30- private sessionStorage : ChatSessionStorage
30+ private tools : Tool [ ] = [ ]
3131
3232 constructor ( tabId ?: string ) {
3333 this . conversationId = randomUUID ( )
3434 this . tabId = tabId ?? randomUUID ( )
35- this . sessionStorage = new ChatSessionStorage ( )
35+ this . tools = tools
3636 }
3737
3838 /**
@@ -178,14 +178,11 @@ export class ChatHistoryManager {
178178 status : ToolResultStatus . ERROR ,
179179 } ) )
180180
181- const session = this . sessionStorage . getSession ( this . tabId )
182- const availableTools = session . pairProgrammingModeOn ? tools : noWriteTools
183-
184181 newUserMessage . userInputMessage . userInputMessageContext = {
185182 shellState : undefined ,
186183 envState : undefined ,
187184 toolResults : toolResults ,
188- tools : availableTools . length === 0 ? undefined : [ ...availableTools ] ,
185+ tools : this . tools . length === 0 ? undefined : [ ...this . tools ] ,
189186 }
190187
191188 return newUserMessage
@@ -202,14 +199,11 @@ export class ChatHistoryManager {
202199 * Adds tool results to the conversation.
203200 */
204201 addToolResults ( toolResults : ToolResult [ ] ) : void {
205- const session = this . sessionStorage . getSession ( this . tabId )
206- const availableTools = session . pairProgrammingModeOn ? tools : noWriteTools
207-
208202 const userInputMessageContext : UserInputMessageContext = {
209203 shellState : undefined ,
210204 envState : undefined ,
211205 toolResults : toolResults ,
212- tools : availableTools . length === 0 ? undefined : [ ...availableTools ] ,
206+ tools : this . tools . length === 0 ? undefined : [ ...this . tools ] ,
213207 }
214208
215209 const msg : UserInputMessage = {
@@ -254,15 +248,12 @@ export class ChatHistoryManager {
254248 status : ToolResultStatus . ERROR ,
255249 } ) )
256250
257- const session = this . sessionStorage . getSession ( this . tabId )
258- const availableTools = session . pairProgrammingModeOn ? tools : noWriteTools
259-
260251 // Create a new user message with cancelled tool results
261252 const userInputMessageContext : UserInputMessageContext = {
262253 shellState : undefined ,
263254 envState : undefined ,
264255 toolResults : toolResults ,
265- tools : availableTools . length === 0 ? undefined : [ ...availableTools ] ,
256+ tools : this . tools . length === 0 ? undefined : [ ...this . tools ] ,
266257 }
267258
268259 const userMessage : ChatMessage = {
0 commit comments