(input any, toolUseData *uctypes.UIMessageDataToolUse)
| 198 | } |
| 199 | |
| 200 | func verifyReadTextFileInput(input any, toolUseData *uctypes.UIMessageDataToolUse) error { |
| 201 | params, err := parseReadTextFileInput(input) |
| 202 | if err != nil { |
| 203 | return err |
| 204 | } |
| 205 | |
| 206 | expandedPath, err := wavebase.ExpandHomeDir(params.Filename) |
| 207 | if err != nil { |
| 208 | return fmt.Errorf("failed to expand path: %w", err) |
| 209 | } |
| 210 | |
| 211 | if !filepath.IsAbs(expandedPath) { |
| 212 | return fmt.Errorf("path must be absolute, got relative path: %s", params.Filename) |
| 213 | } |
| 214 | |
| 215 | if blocked, reason := isBlockedFile(expandedPath); blocked { |
| 216 | return fmt.Errorf("access denied: potentially sensitive file: %s", reason) |
| 217 | } |
| 218 | |
| 219 | fileInfo, err := os.Stat(expandedPath) |
| 220 | if err != nil { |
| 221 | return fmt.Errorf("failed to stat file: %w", err) |
| 222 | } |
| 223 | |
| 224 | if fileInfo.IsDir() { |
| 225 | return fmt.Errorf("path is a directory, cannot be read with the read_text_file tool. use the read_dir tool if available to read directories") |
| 226 | } |
| 227 | |
| 228 | return nil |
| 229 | } |
| 230 | |
| 231 | func readTextFileCallback(input any, toolUseData *uctypes.UIMessageDataToolUse) (any, error) { |
| 232 | const ReadLimit = 1024 * 1024 * 1024 |
nothing calls this directly
no test coverage detected