File tree Expand file tree Collapse file tree 3 files changed +8
-11
lines changed
server/aws-lsp-codewhisperer/src/language-server/agenticChat/tools Expand file tree Collapse file tree 3 files changed +8
-11
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ export class FsRead {
4545 }
4646
4747 public async invoke ( params : FsReadParams ) : Promise < InvokeOutput > {
48+ await this . validate ( params )
4849 try {
4950 const fileContents = await this . readFile ( params . path )
5051 this . logging . info ( `Read file: ${ params . path } , size: ${ fileContents . length } ` )
@@ -115,7 +116,7 @@ export class FsRead {
115116 }
116117 }
117118
118- public static getSpec ( ) {
119+ public getSpec ( ) {
119120 return {
120121 name : 'fsRead' ,
121122 description :
Original file line number Diff line number Diff line change @@ -43,6 +43,7 @@ export class FsWrite {
4343 }
4444
4545 public async invoke ( params : FsWriteParams ) : Promise < InvokeOutput > {
46+ await this . validate ( params )
4647 const sanitizedPath = sanitize ( params . path )
4748
4849 switch ( params . command ) {
@@ -162,7 +163,7 @@ export class FsWrite {
162163 return string . replace ( / [ . * + ? ^ $ { } ( ) | [ \] \\ ] / g, '\\$&' )
163164 }
164165
165- public static getSpec ( ) {
166+ public getSpec ( ) {
166167 return {
167168 name : 'fsWrite' ,
168169 description :
Original file line number Diff line number Diff line change @@ -3,17 +3,12 @@ import { FsRead, FsReadParams } from './fsRead'
33import { FsWrite , FsWriteParams } from './fsWrite'
44
55export const FsToolsServer : Server = ( { workspace, logging, agent } ) => {
6- const fsRead = new FsRead ( { workspace, logging } )
7- const fsWrite = new FsWrite ( { workspace, logging } )
6+ const fsReadTool = new FsRead ( { workspace, logging } )
7+ const fsWriteTool = new FsWrite ( { workspace, logging } )
88
9- agent . addTool ( FsRead . getSpec ( ) , ( input : FsReadParams ) => {
10- return fsRead . invoke ( input )
11- } )
9+ agent . addTool ( fsReadTool . getSpec ( ) , ( input : FsReadParams ) => fsReadTool . invoke ( input ) )
1210
13- agent . addTool ( FsWrite . getSpec ( ) , ( input : FsWriteParams ) => {
14- return fsWrite . invoke ( input )
15- } )
11+ agent . addTool ( fsWriteTool . getSpec ( ) , ( input : FsWriteParams ) => fsWriteTool . invoke ( input ) )
1612
17- // nothing to dispose of.
1813 return ( ) => { }
1914}
You can’t perform that action at this time.
0 commit comments