diff options
| author | Tommaso Sciortino <[email protected]> | 2025-07-07 23:48:44 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-07-08 06:48:44 +0000 |
| commit | 4dab31f1c8f0f4025c5d6a81c1b64f711e066756 (patch) | |
| tree | 3db882e191862e4c24e5653167a756145b567759 /packages/core/src/tools/ls.ts | |
| parent | 137ffec3f6fe035b7edcb478e6c44e66fa593839 (diff) | |
Improve Function Call argument validation and typing (#2881)
Co-authored-by: N. Taylor Mullen <[email protected]>
Diffstat (limited to 'packages/core/src/tools/ls.ts')
| -rw-r--r-- | packages/core/src/tools/ls.ts | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/packages/core/src/tools/ls.ts b/packages/core/src/tools/ls.ts index 6e3869be..df09cc50 100644 --- a/packages/core/src/tools/ls.ts +++ b/packages/core/src/tools/ls.ts @@ -7,6 +7,7 @@ import fs from 'fs'; import path from 'path'; import { BaseTool, ToolResult } from './tools.js'; +import { Type } from '@google/genai'; import { SchemaValidator } from '../utils/schemaValidator.js'; import { makeRelative, shortenPath } from '../utils/paths.js'; import { Config } from '../config/config.js'; @@ -84,23 +85,23 @@ export class LSTool extends BaseTool<LSToolParams, ToolResult> { path: { description: 'The absolute path to the directory to list (must be absolute, not relative)', - type: 'string', + type: Type.STRING, }, ignore: { description: 'List of glob patterns to ignore', items: { - type: 'string', + type: Type.STRING, }, - type: 'array', + type: Type.ARRAY, }, respect_git_ignore: { description: 'Optional: Whether to respect .gitignore patterns when listing files. Only available in git repositories. Defaults to true.', - type: 'boolean', + type: Type.BOOLEAN, }, }, required: ['path'], - type: 'object', + type: Type.OBJECT, }, ); @@ -132,14 +133,9 @@ export class LSTool extends BaseTool<LSToolParams, ToolResult> { * @returns An error message string if invalid, null otherwise */ validateToolParams(params: LSToolParams): string | null { - if ( - this.schema.parameters && - !SchemaValidator.validate( - this.schema.parameters as Record<string, unknown>, - params, - ) - ) { - return 'Parameters failed schema validation.'; + const errors = SchemaValidator.validate(this.schema.parameters, params); + if (errors) { + return errors; } if (!path.isAbsolute(params.path)) { return `Path must be absolute: ${params.path}`; |
