@@ -186,7 +186,7 @@ export class RunInTerminalTool extends Disposable implements IToolImpl {
186
186
}
187
187
188
188
const instance = context . chatSessionId ? this . _sessionTerminalAssociations . get ( context . chatSessionId ) ?. instance : undefined ;
189
- let toolEditedCommand : string | undefined = await this . _rewriteCommandIfNeeded ( context , args , instance , shell ) ;
189
+ let toolEditedCommand : string | undefined = await this . _rewriteCommandIfNeeded ( args , instance , shell ) ;
190
190
if ( toolEditedCommand === args . command ) {
191
191
toolEditedCommand = undefined ;
192
192
}
@@ -211,9 +211,30 @@ export class RunInTerminalTool extends Disposable implements IToolImpl {
211
211
}
212
212
213
213
const args = invocation . parameters as IRunInTerminalInputParams ;
214
- const toolSpecificData = invocation . toolSpecificData as IChatTerminalToolInvocationData | IChatTerminalToolInvocationData2 | undefined ;
214
+
215
+ // Tool specific data is not provided when the invocation is auto-approved. Re-calculate it
216
+ // if needed
217
+ let toolSpecificData = invocation . toolSpecificData as IChatTerminalToolInvocationData | IChatTerminalToolInvocationData2 | undefined ;
215
218
if ( toolSpecificData === undefined ) {
216
- throw new Error ( 'Tool specific data must be provided' ) ;
219
+ const os = await this . _osBackend ;
220
+ const shell = await this . _terminalProfileResolverService . getDefaultShell ( {
221
+ os,
222
+ remoteAuthority : this . _remoteAgentService . getConnection ( ) ?. remoteAuthority
223
+ } ) ;
224
+ const language = os === OperatingSystem . Windows ? 'pwsh' : 'sh' ;
225
+ const instance = invocation . context ?. sessionId ? this . _sessionTerminalAssociations . get ( invocation . context ! . sessionId ) ?. instance : undefined ;
226
+ let toolEditedCommand : string | undefined = await this . _rewriteCommandIfNeeded ( args , instance , shell ) ;
227
+ if ( toolEditedCommand === args . command ) {
228
+ toolEditedCommand = undefined ;
229
+ }
230
+ toolSpecificData = {
231
+ kind : 'terminal2' ,
232
+ commandLine : {
233
+ original : args . command ,
234
+ toolEdited : toolEditedCommand
235
+ } ,
236
+ language
237
+ } ;
217
238
}
218
239
219
240
this . _logService . debug ( `RunInTerminalTool: Invoking with options ${ JSON . stringify ( args ) } ` ) ;
@@ -397,7 +418,7 @@ export class RunInTerminalTool extends Disposable implements IToolImpl {
397
418
}
398
419
}
399
420
400
- protected async _rewriteCommandIfNeeded ( context : IToolInvocationPreparationContext , args : IRunInTerminalInputParams , instance : Pick < ITerminalInstance , 'getCwdResource' > | undefined , shell : string ) : Promise < string > {
421
+ protected async _rewriteCommandIfNeeded ( args : IRunInTerminalInputParams , instance : Pick < ITerminalInstance , 'getCwdResource' > | undefined , shell : string ) : Promise < string > {
401
422
const commandLine = args . command ;
402
423
const os = await this . _osBackend ;
403
424
@@ -604,7 +625,7 @@ class BackgroundTerminalExecution extends Disposable {
604
625
super ( ) ;
605
626
606
627
this . _startMarker = this . _register ( this . _xterm . raw . registerMarker ( ) ) ;
607
- this . _instance . runCommand ( this . _commandLine ) ;
628
+ this . _instance . runCommand ( this . _commandLine , true ) ;
608
629
}
609
630
610
631
getOutput ( ) : string {
0 commit comments