diff options
Diffstat (limited to 'packages/core/src/utils/fileUtils.ts')
| -rw-r--r-- | packages/core/src/utils/fileUtils.ts | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/packages/core/src/utils/fileUtils.ts b/packages/core/src/utils/fileUtils.ts index 30ab69c6..92186e4f 100644 --- a/packages/core/src/utils/fileUtils.ts +++ b/packages/core/src/utils/fileUtils.ts @@ -195,10 +195,18 @@ export async function detectFileType( return 'text'; } +export enum FileErrorType { + FILE_NOT_FOUND = 'FILE_NOT_FOUND', + IS_DIRECTORY = 'IS_DIRECTORY', + FILE_TOO_LARGE = 'FILE_TOO_LARGE', + READ_ERROR = 'READ_ERROR', +} + export interface ProcessedFileReadResult { llmContent: PartUnion; // string for text, Part for image/pdf/unreadable binary returnDisplay: string; error?: string; // Optional error message for the LLM if file processing failed + errorType?: FileErrorType; // Structured error type using enum isTruncated?: boolean; // For text files, indicates if content was truncated originalLineCount?: number; // For text files linesShown?: [number, number]; // For text files [startLine, endLine] (1-based for display) @@ -225,6 +233,7 @@ export async function processSingleFileContent( llmContent: '', returnDisplay: 'File not found.', error: `File not found: ${filePath}`, + errorType: FileErrorType.FILE_NOT_FOUND, }; } const stats = await fs.promises.stat(filePath); @@ -233,6 +242,7 @@ export async function processSingleFileContent( llmContent: '', returnDisplay: 'Path is a directory.', error: `Path is a directory, not a file: ${filePath}`, + errorType: FileErrorType.IS_DIRECTORY, }; } |
