@@ -50,7 +50,12 @@ import { Change } from 'diff'
5050import { FsWriteParams } from '../../../tools/fsWrite'
5151import { AsyncEventProgressMessage } from '../../../../amazonq/commons/connector/connectorMessages'
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 }
@@ -242,10 +247,11 @@ export class Messenger {
242247 const chatStream = new ChatStream ( this , tabID , triggerID , toolUse , validation , changeList )
243248 await ToolUtils . queueDescription ( tool , chatStream )
244249
250+ const actionId =
251+ tool . type === ToolType . ExecuteBash ? 'run-shell-command' : 'generic-tool-execution'
252+
245253 this . dispatcher . sendCustomFormActionMessage (
246- new CustomFormActionMessage ( tabID , {
247- id : 'generic-tool-execution' ,
248- } )
254+ new CustomFormActionMessage ( tabID , { id : actionId } )
249255 )
250256 } else {
251257 // TODO: Handle the error
@@ -450,12 +456,28 @@ export class Messenger {
450456 ) {
451457 const buttons : ChatItemButton [ ] = [ ]
452458 let fileList : ChatItemContent [ 'fileList' ] = undefined
453- if ( validation . requiresAcceptance && toolUse ?. name === ToolType . ExecuteBash ) {
454- buttons . push ( {
455- id : 'confirm-tool-use' ,
456- text : 'Confirm' ,
457- status : 'info' ,
458- } )
459+ let shellCommandHeader = undefined
460+ if ( toolUse ?. name === ToolType . ExecuteBash && message . startsWith ( '```shell' ) ) {
461+ if ( validation . requiresAcceptance ) {
462+ buttons . push ( {
463+ id : 'run-shell-command' ,
464+ text : 'Run' ,
465+ status : 'main' ,
466+ icon : 'play' as MynahIconsType ,
467+ } )
468+ buttons . push ( {
469+ id : 'reject-shell-command' ,
470+ text : 'Reject' ,
471+ status : 'clear' ,
472+ icon : 'cancel' as MynahIconsType ,
473+ } )
474+ }
475+
476+ shellCommandHeader = {
477+ icon : 'code-block' as MynahIconsType ,
478+ body : 'shell' ,
479+ buttons : buttons ,
480+ }
459481
460482 if ( validation . warning ) {
461483 message = validation . warning + message
@@ -514,16 +536,23 @@ export class Messenger {
514536 codeBlockLanguage : undefined ,
515537 contextList : undefined ,
516538 canBeVoted : false ,
517- buttons : toolUse ?. name === ToolType . FsWrite ? undefined : buttons ,
518- fullWidth : toolUse ?. name === ToolType . FsWrite ,
519- padding : ! ( toolUse ?. name === ToolType . FsWrite ) ,
539+ buttons :
540+ toolUse ?. name === ToolType . FsWrite || toolUse ?. name === ToolType . ExecuteBash
541+ ? undefined
542+ : buttons ,
543+ fullWidth : toolUse ?. name === ToolType . FsWrite || toolUse ?. name === ToolType . ExecuteBash ,
544+ padding : ! ( toolUse ?. name === ToolType . FsWrite || toolUse ?. name === ToolType . ExecuteBash ) ,
520545 header :
521546 toolUse ?. name === ToolType . FsWrite
522547 ? { icon : 'code-block' as MynahIconsType , buttons : buttons , fileList : fileList }
523- : undefined ,
548+ : toolUse ?. name === ToolType . ExecuteBash
549+ ? shellCommandHeader
550+ : undefined ,
524551 codeBlockActions :
525- // eslint-disable-next-line unicorn/no-null, prettier/prettier
526- toolUse ?. name === ToolType . FsWrite ? { 'insert-to-cursor' : null , copy : null } : undefined ,
552+ toolUse ?. name === ToolType . FsWrite || toolUse ?. name === ToolType . ExecuteBash
553+ ? // eslint-disable-next-line unicorn/no-null
554+ { 'insert-to-cursor' : null , copy : null }
555+ : undefined ,
527556 } ,
528557 tabID
529558 )
@@ -575,6 +604,10 @@ export class Messenger {
575604 ]
576605 followUpsHeader = 'Try Examples:'
577606 break
607+ case 'reject-shell-command' :
608+ // need to update the string later
609+ message = 'The shell command execution rejected. Abort.'
610+ break
578611 }
579612
580613 this . dispatcher . sendChatMessage (
0 commit comments