Harden Harness runtime, persistence and execution for Hand
This commit is contained in:
1 parent
09c30fe2d5
commit
0972eed3ea
164 files changed
+15912
-506
No files matched your search
@@ -15,7 +15,8 @@ import (
|
||||
|
||||
// ReadFileTool reads the contents of a file.
|
||||
type ReadFileTool struct {
|
||||
WorkDir string // if set, restricts reads to this directory
|
||||
ExactPath bool // preserve admitted path spelling; no home or Unicode recovery
|
||||
WorkDir string // if set, restricts reads to this directory
|
||||
}
|
||||
|
||||
type readFileInput struct {
|
||||
@@ -82,11 +83,15 @@ func (t *ReadFileTool) Execute(ctx context.Context, input json.RawMessage) (tool
|
||||
return tool.ToolResult{Error: "path is required"}, nil
|
||||
}
|
||||
|
||||
in.Path = tool.ExpandHome(in.Path)
|
||||
if !t.ExactPath {
|
||||
in.Path = tool.ExpandHome(in.Path)
|
||||
}
|
||||
if t.WorkDir != "" && !filepath.IsAbs(in.Path) {
|
||||
in.Path = filepath.Join(t.WorkDir, in.Path)
|
||||
}
|
||||
in.Path = tool.ResolveExistingPath(in.Path)
|
||||
if !t.ExactPath {
|
||||
in.Path = tool.ResolveExistingPath(in.Path)
|
||||
}
|
||||
|
||||
if t.WorkDir != "" {
|
||||
if err := tool.ValidatePathInWorkDir(in.Path, t.WorkDir); err != nil {
|
||||
|
||||
Reference in new issue
Block a user