(
params: WriteFileToolParams,
)
| 415 | } |
| 416 | |
| 417 | protected override validateToolParams( |
| 418 | params: WriteFileToolParams, |
| 419 | ): string | null { |
| 420 | const errors = SchemaValidator.validate( |
| 421 | this.schema.parametersJsonSchema, |
| 422 | params, |
| 423 | ); |
| 424 | if (errors) { |
| 425 | return errors; |
| 426 | } |
| 427 | |
| 428 | const filePath = params.file_path; |
| 429 | |
| 430 | if (!filePath) { |
| 431 | return `Missing or empty "file_path"`; |
| 432 | } |
| 433 | |
| 434 | if (!path.isAbsolute(filePath)) { |
| 435 | return `File path must be absolute: ${filePath}`; |
| 436 | } |
| 437 | |
| 438 | const workspaceContext = this.config.getWorkspaceContext(); |
| 439 | if (!workspaceContext.isPathWithinWorkspace(filePath)) { |
| 440 | const directories = workspaceContext.getDirectories(); |
| 441 | return `File path must be within one of the workspace directories: ${directories.join( |
| 442 | ', ', |
| 443 | )}`; |
| 444 | } |
| 445 | |
| 446 | try { |
| 447 | if (fs.existsSync(filePath)) { |
| 448 | const stats = fs.lstatSync(filePath); |
| 449 | if (stats.isDirectory()) { |
| 450 | return `Path is a directory, not a file: ${filePath}`; |
| 451 | } |
| 452 | } |
| 453 | } catch (statError: unknown) { |
| 454 | return `Error accessing path properties for validation: ${filePath}. Reason: ${ |
| 455 | statError instanceof Error ? statError.message : String(statError) |
| 456 | }`; |
| 457 | } |
| 458 | |
| 459 | return null; |
| 460 | } |
| 461 | |
| 462 | protected createInvocation( |
| 463 | params: WriteFileToolParams, |
nothing calls this directly
no test coverage detected