summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeo <[email protected]>2025-06-01 19:18:43 +0100
committerGitHub <[email protected]>2025-06-01 11:18:43 -0700
commitedc12e416d0b9daf24ede50cb18b012cb2b6e18a (patch)
tree3c04e0685181948c016ed8663b980195fb05a788
parent9dae07784b82e9cc3306fa146de2956d574daa2d (diff)
Update edit tool validation function to override validateToolParams (#667)
-rw-r--r--packages/core/src/tools/edit.test.ts10
-rw-r--r--packages/core/src/tools/edit.ts4
2 files changed, 8 insertions, 6 deletions
diff --git a/packages/core/src/tools/edit.test.ts b/packages/core/src/tools/edit.test.ts
index 08d0860d..e0de98d5 100644
--- a/packages/core/src/tools/edit.test.ts
+++ b/packages/core/src/tools/edit.test.ts
@@ -178,14 +178,14 @@ describe('EditTool', () => {
});
});
- describe('validateParams', () => {
+ describe('validateToolParams', () => {
it('should return null for valid params', () => {
const params: EditToolParams = {
file_path: path.join(rootDir, 'test.txt'),
old_string: 'old',
new_string: 'new',
};
- expect(tool.validateParams(params)).toBeNull();
+ expect(tool.validateToolParams(params)).toBeNull();
});
it('should return error for relative path', () => {
@@ -194,7 +194,9 @@ describe('EditTool', () => {
old_string: 'old',
new_string: 'new',
};
- expect(tool.validateParams(params)).toMatch(/File path must be absolute/);
+ expect(tool.validateToolParams(params)).toMatch(
+ /File path must be absolute/,
+ );
});
it('should return error for path outside root', () => {
@@ -203,7 +205,7 @@ describe('EditTool', () => {
old_string: 'old',
new_string: 'new',
};
- expect(tool.validateParams(params)).toMatch(
+ expect(tool.validateToolParams(params)).toMatch(
/File path must be within the root directory/,
);
});
diff --git a/packages/core/src/tools/edit.ts b/packages/core/src/tools/edit.ts
index d85c89b0..3ef7e986 100644
--- a/packages/core/src/tools/edit.ts
+++ b/packages/core/src/tools/edit.ts
@@ -126,7 +126,7 @@ Expectation for parameters:
* @param params Parameters to validate
* @returns Error message string or null if valid
*/
- validateParams(params: EditToolParams): string | null {
+ validateToolParams(params: EditToolParams): string | null {
if (
this.schema.parameters &&
!SchemaValidator.validate(
@@ -372,7 +372,7 @@ Expectation for parameters:
params: EditToolParams,
_signal: AbortSignal,
): Promise<ToolResult> {
- const validationError = this.validateParams(params);
+ const validationError = this.validateToolParams(params);
if (validationError) {
return {
llmContent: `Error: Invalid parameters provided. Reason: ${validationError}`,