File tree Expand file tree Collapse file tree 2 files changed +169
-126
lines changed Expand file tree Collapse file tree 2 files changed +169
-126
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,6 @@ import { IModuleInstaller } from '../common/installer/types';
2626import { ModuleInstallerType } from '../pythonEnvironments/info' ;
2727import { IDiscoveryAPI } from '../pythonEnvironments/base/locator' ;
2828import { getEnvExtApi , useEnvExtension } from '../envExt/api.internal' ;
29- import { traceError } from '../logging' ;
3029
3130export interface IInstallPackageArgs extends IResourceReference {
3231 packageList : string [ ] ;
@@ -55,15 +54,18 @@ export class InstallPackagesTool implements LanguageModelTool<IInstallPackageArg
5554 if ( useEnvExtension ( ) ) {
5655 const api = await getEnvExtApi ( ) ;
5756 const env = await api . getEnvironment ( resourcePath ) ;
58- if ( env && ( api as Partial < typeof api > ) . installPackages ) {
59- await raceCancellationError ( api . installPackages ( env , options . input . packageList ) , token ) ;
57+ if ( env ) {
58+ await raceCancellationError ( api . managePackages ( env , { install : options . input . packageList } ) , token ) ;
6059 const resultMessage = `Successfully installed ${ packagePlurality } : ${ options . input . packageList . join (
6160 ', ' ,
6261 ) } `;
6362 return new LanguageModelToolResult ( [ new LanguageModelTextPart ( resultMessage ) ] ) ;
64- }
65- if ( env && ! ( api as Partial < typeof api > ) . installPackages ) {
66- traceError ( `API does not expose installPackages method for environment: ${ env . displayName } ` ) ;
63+ } else {
64+ return new LanguageModelToolResult ( [
65+ new LanguageModelTextPart (
66+ `Packages not installed. No environment found for: ${ resourcePath ?. fsPath } ` ,
67+ ) ,
68+ ] ) ;
6769 }
6870 }
6971
You can’t perform that action at this time.
0 commit comments