Skip to content

Commit

Permalink
fix: adjust relative credential paths for tool refs
Browse files Browse the repository at this point in the history
Signed-off-by: Donnie Adams <[email protected]>
  • Loading branch information
thedadams committed Jan 14, 2025
1 parent c9248d8 commit d7e5abb
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions pkg/controller/creds/creds.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"net/url"
"path"
"path/filepath"
"slices"
"strings"

Expand Down Expand Up @@ -149,16 +150,13 @@ func toolRefsFromTools(parentTool gptscript.Tool, parentRef toolRef, tools []str

func fullToolPathName(parentRef toolRef, name string) string {
toolName, subTool := gtypes.SplitToolRef(name)

// If this tool's path is relative to its parent.
if strings.HasPrefix(toolName, ".") {
parentToolName, _ := gtypes.SplitToolRef(parentRef.Reference)
if !path.IsAbs(parentToolName) {
if !strings.HasPrefix(parentToolName, ".") {
parentToolName, _ = gtypes.SplitToolRef(parentRef.name)
} else {
parentToolName = path.Join(parentRef.name, parentToolName)
}
parentToolName, _ := gtypes.SplitToolRef(parentRef.name)
if rel, err := filepath.Rel(parentToolName, toolName); err == nil && strings.HasPrefix(toolName, parentToolName) {
toolName = rel
}

refURL, err := url.Parse(parentToolName)
if err != nil {
return ""
Expand Down

0 comments on commit d7e5abb

Please sign in to comment.