@@ -50,7 +50,12 @@ import { Change } from 'diff'
50
50
import { FsWriteParams } from '../../../tools/fsWrite'
51
51
import { AsyncEventProgressMessage } from '../../../../amazonq/commons/connector/connectorMessages'
52
52
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'
54
59
55
60
export type MessengerResponseType = {
56
61
$metadata : { requestId ?: string ; httpStatusCode ?: number }
@@ -242,10 +247,11 @@ export class Messenger {
242
247
const chatStream = new ChatStream ( this , tabID , triggerID , toolUse , validation , changeList )
243
248
await ToolUtils . queueDescription ( tool , chatStream )
244
249
250
+ const actionId =
251
+ tool . type === ToolType . ExecuteBash ? 'run-shell-command' : 'generic-tool-execution'
252
+
245
253
this . dispatcher . sendCustomFormActionMessage (
246
- new CustomFormActionMessage ( tabID , {
247
- id : 'generic-tool-execution' ,
248
- } )
254
+ new CustomFormActionMessage ( tabID , { id : actionId } )
249
255
)
250
256
} else {
251
257
// TODO: Handle the error
@@ -450,12 +456,28 @@ export class Messenger {
450
456
) {
451
457
const buttons : ChatItemButton [ ] = [ ]
452
458
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
+ }
459
481
460
482
if ( validation . warning ) {
461
483
message = validation . warning + message
@@ -514,16 +536,23 @@ export class Messenger {
514
536
codeBlockLanguage : undefined ,
515
537
contextList : undefined ,
516
538
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 ) ,
520
545
header :
521
546
toolUse ?. name === ToolType . FsWrite
522
547
? { icon : 'code-block' as MynahIconsType , buttons : buttons , fileList : fileList }
523
- : undefined ,
548
+ : toolUse ?. name === ToolType . ExecuteBash
549
+ ? shellCommandHeader
550
+ : undefined ,
524
551
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 ,
527
556
} ,
528
557
tabID
529
558
)
@@ -575,6 +604,10 @@ export class Messenger {
575
604
]
576
605
followUpsHeader = 'Try Examples:'
577
606
break
607
+ case 'reject-shell-command' :
608
+ // need to update the string later
609
+ message = 'The shell command execution rejected. Abort.'
610
+ break
578
611
}
579
612
580
613
this . dispatcher . sendChatMessage (
0 commit comments