feat(core): Cleanup after migrating tools. (#6199)

Co-authored-by: Jacob Richman <jacob314@gmail.com>
This commit is contained in:
joshualitt
2025-08-19 13:55:06 -07:00
committed by GitHub
parent 2143731f6e
commit b9cece767d
17 changed files with 86 additions and 132 deletions

View File

@@ -7,6 +7,7 @@
import { FunctionDeclaration, PartListUnion } from '@google/genai';
import { ToolErrorType } from './tool-error.js';
import { DiffUpdateResult } from '../ide/ideContext.js';
import { SchemaValidator } from '../utils/schemaValidator.js';
/**
* Represents a validated and ready-to-execute tool call.
@@ -170,7 +171,7 @@ export abstract class DeclarativeTool<
* @param params The raw parameters from the model.
* @returns An error message string if invalid, null otherwise.
*/
protected validateToolParams(_params: TParams): string | null {
validateToolParams(_params: TParams): string | null {
// Base implementation can be extended by subclasses.
return null;
}
@@ -278,6 +279,23 @@ export abstract class BaseDeclarativeTool<
return this.createInvocation(params);
}
override validateToolParams(params: TParams): string | null {
const errors = SchemaValidator.validate(
this.schema.parametersJsonSchema,
params,
);
if (errors) {
return errors;
}
return this.validateToolParamValues(params);
}
protected validateToolParamValues(_params: TParams): string | null {
// Base implementation can be extended by subclasses.
return null;
}
protected abstract createInvocation(
params: TParams,
): ToolInvocation<TParams, TResult>;