summaryrefslogtreecommitdiff
path: root/packages/server/src/tools/read-file.ts
diff options
context:
space:
mode:
authorTaylor Mullen <[email protected]>2025-04-20 22:10:23 -0400
committerN. Taylor Mullen <[email protected]>2025-04-20 22:13:55 -0400
commit63f864cdd79a0357ec1e0474586fb00a0ec7d91b (patch)
tree4f70dd65b2cd0eef5e147fa514488ba259a327e6 /packages/server/src/tools/read-file.ts
parentc095091853b70affdd9cf2cc6cc590451c658c1f (diff)
Fix read-file from exploding with path not found error.
- There were a few hiccups here. Somehow 2.5-flash wasn't actually abiding by our tool schema. Instead it was inferring `path`. To semi-combat this I've renamed `file_path` -> `path`. - We weren't elevating errors that were created via schema validation. Instead both the `glob` and `read-file.ts` now surface this. - In error scenarios (like failing schema) we were improperly surfacing these as success cases because we were overriding tool status.
Diffstat (limited to 'packages/server/src/tools/read-file.ts')
-rw-r--r--packages/server/src/tools/read-file.ts14
1 files changed, 7 insertions, 7 deletions
diff --git a/packages/server/src/tools/read-file.ts b/packages/server/src/tools/read-file.ts
index 9d053003..52856e42 100644
--- a/packages/server/src/tools/read-file.ts
+++ b/packages/server/src/tools/read-file.ts
@@ -17,7 +17,7 @@ export interface ReadFileToolParams {
/**
* The absolute path to the file to read
*/
- file_path: string;
+ path: string;
/**
* The line number to start reading from (optional)
@@ -46,7 +46,7 @@ export class ReadFileLogic extends BaseTool<ReadFileToolParams, ToolResult> {
'', // Description handled by CLI wrapper
{
properties: {
- file_path: {
+ path: {
description:
"The absolute path to the file to read (e.g., '/home/user/project/file.txt'). Relative paths are not supported.",
type: 'string',
@@ -62,7 +62,7 @@ export class ReadFileLogic extends BaseTool<ReadFileToolParams, ToolResult> {
type: 'number',
},
},
- required: ['file_path'],
+ required: ['path'],
type: 'object',
},
);
@@ -101,7 +101,7 @@ export class ReadFileLogic extends BaseTool<ReadFileToolParams, ToolResult> {
) {
return 'Parameters failed schema validation.';
}
- const filePath = params.file_path;
+ const filePath = params.path;
if (!path.isAbsolute(filePath)) {
return `File path must be absolute: ${filePath}`;
}
@@ -185,7 +185,7 @@ export class ReadFileLogic extends BaseTool<ReadFileToolParams, ToolResult> {
* @returns A string describing the file being read
*/
getDescription(params: ReadFileToolParams): string {
- const relativePath = makeRelative(params.file_path, this.rootDirectory);
+ const relativePath = makeRelative(params.path, this.rootDirectory);
return shortenPath(relativePath);
}
@@ -199,11 +199,11 @@ export class ReadFileLogic extends BaseTool<ReadFileToolParams, ToolResult> {
if (validationError) {
return {
llmContent: `Error: Invalid parameters provided. Reason: ${validationError}`,
- returnDisplay: '**Error:** Failed to execute tool.',
+ returnDisplay: validationError,
};
}
- const filePath = params.file_path;
+ const filePath = params.path;
try {
if (!fs.existsSync(filePath)) {
return {