diff options
| author | joshualitt <[email protected]> | 2025-08-19 13:55:06 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-08-19 20:55:06 +0000 |
| commit | b9cece767d1abccd06fb95cab759afd06cc2c1e1 (patch) | |
| tree | 8c29a49bbaedd0a706bd2dba82eb4c587797ba7e /packages/core/src/tools/tools.ts | |
| parent | 2143731f6efdf1aafff38ec249caf01a8bcd163e (diff) | |
feat(core): Cleanup after migrating tools. (#6199)
Co-authored-by: Jacob Richman <[email protected]>
Diffstat (limited to 'packages/core/src/tools/tools.ts')
| -rw-r--r-- | packages/core/src/tools/tools.ts | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/packages/core/src/tools/tools.ts b/packages/core/src/tools/tools.ts index deb54cf6..761b670a 100644 --- a/packages/core/src/tools/tools.ts +++ b/packages/core/src/tools/tools.ts @@ -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>; |
