(input any, toolUseData *uctypes.UIMessageDataToolUse)
| 54 | } |
| 55 | |
| 56 | func verifyReadDirInput(input any, toolUseData *uctypes.UIMessageDataToolUse) error { |
| 57 | params, err := parseReadDirInput(input) |
| 58 | if err != nil { |
| 59 | return err |
| 60 | } |
| 61 | |
| 62 | expandedPath, err := wavebase.ExpandHomeDir(params.Path) |
| 63 | if err != nil { |
| 64 | return fmt.Errorf("failed to expand path: %w", err) |
| 65 | } |
| 66 | |
| 67 | if !filepath.IsAbs(expandedPath) { |
| 68 | return fmt.Errorf("path must be absolute, got relative path: %s", params.Path) |
| 69 | } |
| 70 | |
| 71 | fileInfo, err := os.Stat(expandedPath) |
| 72 | if err != nil { |
| 73 | return fmt.Errorf("failed to stat path: %w", err) |
| 74 | } |
| 75 | |
| 76 | if !fileInfo.IsDir() { |
| 77 | return fmt.Errorf("path is not a directory, cannot be read with the read_dir tool. use the read_text_file tool if available to read files") |
| 78 | } |
| 79 | |
| 80 | return nil |
| 81 | } |
| 82 | |
| 83 | func readDirCallback(input any, toolUseData *uctypes.UIMessageDataToolUse) (any, error) { |
| 84 | params, err := parseReadDirInput(input) |
nothing calls this directly
no test coverage detected