@@ -3,6 +3,7 @@ package tools
3
3
import (
4
4
"context"
5
5
"fmt"
6
+ "path/filepath"
6
7
"strings"
7
8
"time"
8
9
@@ -51,12 +52,29 @@ func ResolveToolReferences(ctx context.Context, gptClient *gptscript.GPTScript,
51
52
return result , nil
52
53
}
53
54
54
- for _ , peerToolID := range tool .LocalTools {
55
+ var exportToolIDs []string
56
+ for _ , export := range tool .Export {
57
+ tools := tool .ToolMapping [export ]
58
+ for _ , t := range tools {
59
+ exportToolIDs = append (exportToolIDs , t .ToolID )
60
+ }
61
+ }
62
+
63
+ for _ , peerToolID := range exportToolIDs {
55
64
if peerToolID == prg .EntryToolID {
56
65
continue
57
66
}
58
67
59
68
peerTool := prg .ToolSet [peerToolID ]
69
+ ref , _ , _ := strings .Cut (peerToolID , ":" )
70
+ toolRef := reference
71
+ if strings .HasPrefix (ref , "./" ) || strings .HasPrefix (ref , "../" ) {
72
+ relPath , err := filepath .Rel (peerTool .WorkingDir , ref )
73
+ if err != nil {
74
+ return nil , err
75
+ }
76
+ toolRef = filepath .Join (toolRef , relPath )
77
+ }
60
78
if isValidTool (peerTool ) {
61
79
toolName := resolveToolReferenceName (toolType , false , peerTool .MetaData ["category" ] == "Capability" , name , peerTool .Name )
62
80
result = append (result , & v1.ToolReference {
@@ -68,7 +86,7 @@ func ResolveToolReferences(ctx context.Context, gptClient *gptscript.GPTScript,
68
86
},
69
87
Spec : v1.ToolReferenceSpec {
70
88
Type : toolType ,
71
- Reference : fmt .Sprintf ("%s from %s" , peerTool .Name , reference ),
89
+ Reference : fmt .Sprintf ("%s from %s" , peerTool .Name , toolRef ),
72
90
Builtin : builtin ,
73
91
BundleToolName : entryTool .Name ,
74
92
},
0 commit comments