@@ -26,8 +26,8 @@ const credentialHelpersRepo = "github.com/gptscript-ai/gptscript-credential-help
2626
2727type Runtime interface {
2828 ID () string
29- Supports (cmd []string ) bool
30- Setup (ctx context.Context , dataRoot , toolSource string , env []string ) ([]string , error )
29+ Supports (tool types. Tool , cmd []string ) bool
30+ Setup (ctx context.Context , tool types. Tool , dataRoot , toolSource string , env []string ) ([]string , error )
3131}
3232
3333type noopRuntime struct {
@@ -37,11 +37,11 @@ func (n noopRuntime) ID() string {
3737 return "none"
3838}
3939
40- func (n noopRuntime ) Supports (_ []string ) bool {
40+ func (n noopRuntime ) Supports (_ types. Tool , _ []string ) bool {
4141 return false
4242}
4343
44- func (n noopRuntime ) Setup (_ context.Context , _ , _ string , _ []string ) ([]string , error ) {
44+ func (n noopRuntime ) Setup (_ context.Context , _ types. Tool , _ , _ string , _ []string ) ([]string , error ) {
4545 return nil , nil
4646}
4747
@@ -52,7 +52,6 @@ type Manager struct {
5252 credHelperDirs credentials.CredentialHelperDirs
5353 runtimes []Runtime
5454 credHelperConfig * credHelperConfig
55- supportLocal bool
5655}
5756
5857type credHelperConfig struct {
@@ -62,10 +61,6 @@ type credHelperConfig struct {
6261 env []string
6362}
6463
65- func (m * Manager ) SetSupportLocal () {
66- m .supportLocal = true
67- }
68-
6964func New (cacheDir string , runtimes ... Runtime ) * Manager {
7065 root := filepath .Join (cacheDir , "repos" )
7166 return & Manager {
@@ -216,7 +211,7 @@ func (m *Manager) setup(ctx context.Context, runtime Runtime, tool types.Tool, e
216211 }
217212 }
218213
219- newEnv , err := runtime .Setup (ctx , m .runtimeDir , targetFinal , env )
214+ newEnv , err := runtime .Setup (ctx , tool , m .runtimeDir , targetFinal , env )
220215 if err != nil {
221216 return "" , nil , err
222217 }
@@ -240,17 +235,10 @@ func (m *Manager) setup(ctx context.Context, runtime Runtime, tool types.Tool, e
240235
241236func (m * Manager ) GetContext (ctx context.Context , tool types.Tool , cmd , env []string ) (string , []string , error ) {
242237 var isLocal bool
243- if ! m .supportLocal {
244- if tool .Source .Repo == nil {
245- return tool .WorkingDir , env , nil
246- }
247-
248- if tool .Source .Repo .VCS != "git" {
249- return "" , nil , fmt .Errorf ("only git is supported, found VCS %s for %s" , tool .Source .Repo .VCS , tool .ID )
250- }
251- } else if tool .Source .Repo == nil {
238+ if tool .Source .Repo == nil {
252239 isLocal = true
253- id := hash .Digest (tool )[:12 ]
240+ d , _ := json .Marshal (tool )
241+ id := hash .Digest (d )[:12 ]
254242 tool .Source .Repo = & types.Repo {
255243 VCS : "<local>" ,
256244 Root : id ,
@@ -261,7 +249,7 @@ func (m *Manager) GetContext(ctx context.Context, tool types.Tool, cmd, env []st
261249 }
262250
263251 for _ , runtime := range m .runtimes {
264- if runtime .Supports (cmd ) {
252+ if runtime .Supports (tool , cmd ) {
265253 log .Debugf ("Runtime %s supports %v" , runtime .ID (), cmd )
266254 return m .setup (ctx , runtime , tool , env )
267255 }
0 commit comments