@@ -50,7 +50,12 @@ import { noWriteTools, tools } from '../../../constants'
5050import { Change } from 'diff'
5151import { FsWriteParams } from '../../../tools/fsWrite'
5252
53- export type StaticTextResponseType = 'quick-action-help' | 'onboarding-help' | 'transform' | 'help'
53+ export type StaticTextResponseType =
54+ | 'quick-action-help'
55+ | 'onboarding-help'
56+ | 'transform'
57+ | 'help'
58+ | 'reject-shell-command'
5459
5560export type MessengerResponseType = {
5661 $metadata : { requestId ?: string ; httpStatusCode ?: number }
@@ -269,12 +274,20 @@ export class Messenger {
269274 }
270275
271276 if ( ! validation . requiresAcceptance ) {
272- // Need separate id for read tool and safe bash command execution as 'confirm-tool-use' id is required to change button status from `Confirm` to `Confirmed` state in cwChatConnector.ts which will impact generic tool execution.
273- this . dispatcher . sendCustomFormActionMessage (
274- new CustomFormActionMessage ( tabID , {
275- id : 'generic-tool-execution' ,
276- } )
277- )
277+ // Need separate id for read tool and safe bash command execution as 'run-shell-command' id is required to state in cwChatConnector.ts which will impact generic tool execution.
278+ if ( tool . type === ToolType . ExecuteBash ) {
279+ this . dispatcher . sendCustomFormActionMessage (
280+ new CustomFormActionMessage ( tabID , {
281+ id : 'run-shell-command' ,
282+ } )
283+ )
284+ } else {
285+ this . dispatcher . sendCustomFormActionMessage (
286+ new CustomFormActionMessage ( tabID , {
287+ id : 'generic-tool-execution' ,
288+ } )
289+ )
290+ }
278291 }
279292 } else {
280293 // TODO: Handle the error
@@ -500,12 +513,28 @@ export class Messenger {
500513 ) {
501514 const buttons : ChatItemButton [ ] = [ ]
502515 let fileList : ChatItemContent [ 'fileList' ] = undefined
503- if ( validation . requiresAcceptance && toolUse ?. name === ToolType . ExecuteBash ) {
504- buttons . push ( {
505- id : 'confirm-tool-use' ,
506- text : 'Confirm' ,
507- status : 'info' ,
508- } )
516+ let shellCommandHeader = undefined
517+ if ( toolUse ?. name === ToolType . ExecuteBash && message . startsWith ( '```shell' ) ) {
518+ if ( validation . requiresAcceptance ) {
519+ buttons . push ( {
520+ id : 'run-shell-command' ,
521+ text : 'Run' ,
522+ status : 'main' ,
523+ icon : 'play' as MynahIconsType ,
524+ } )
525+ buttons . push ( {
526+ id : 'reject-shell-command' ,
527+ text : 'Reject' ,
528+ status : 'clear' ,
529+ icon : 'cancel' as MynahIconsType ,
530+ } )
531+ }
532+
533+ shellCommandHeader = {
534+ icon : 'code-block' as MynahIconsType ,
535+ body : 'shell' ,
536+ buttons : buttons ,
537+ }
509538
510539 if ( validation . warning ) {
511540 message = validation . warning + message
@@ -564,16 +593,23 @@ export class Messenger {
564593 codeBlockLanguage : undefined ,
565594 contextList : undefined ,
566595 canBeVoted : false ,
567- buttons : toolUse ?. name === ToolType . FsWrite ? undefined : buttons ,
568- fullWidth : toolUse ?. name === ToolType . FsWrite ,
569- padding : ! ( toolUse ?. name === ToolType . FsWrite ) ,
596+ buttons :
597+ toolUse ?. name === ToolType . FsWrite || toolUse ?. name === ToolType . ExecuteBash
598+ ? undefined
599+ : buttons ,
600+ fullWidth : toolUse ?. name === ToolType . FsWrite || toolUse ?. name === ToolType . ExecuteBash ,
601+ padding : ! ( toolUse ?. name === ToolType . FsWrite || toolUse ?. name === ToolType . ExecuteBash ) ,
570602 header :
571603 toolUse ?. name === ToolType . FsWrite
572604 ? { icon : 'code-block' as MynahIconsType , buttons : buttons , fileList : fileList }
573- : undefined ,
605+ : toolUse ?. name === ToolType . ExecuteBash
606+ ? shellCommandHeader
607+ : undefined ,
574608 codeBlockActions :
575609 // eslint-disable-next-line unicorn/no-null, prettier/prettier
576- toolUse ?. name === ToolType . FsWrite ? { 'insert-to-cursor' : null , copy : null } : undefined ,
610+ toolUse ?. name === ToolType . FsWrite || toolUse ?. name === ToolType . ExecuteBash
611+ ? { 'insert-to-cursor' : null , copy : null }
612+ : undefined ,
577613 } ,
578614 tabID
579615 )
@@ -625,6 +661,10 @@ export class Messenger {
625661 ]
626662 followUpsHeader = 'Try Examples:'
627663 break
664+ case 'reject-shell-command' :
665+ // need to update the string later
666+ message = 'The shell command execution rejected. Abort.'
667+ break
628668 }
629669
630670 this . dispatcher . sendChatMessage (
0 commit comments