summaryrefslogtreecommitdiff
path: root/packages/core/src/tools/shell.ts
diff options
context:
space:
mode:
authorTommaso Sciortino <[email protected]>2025-07-07 23:48:44 -0700
committerGitHub <[email protected]>2025-07-08 06:48:44 +0000
commit4dab31f1c8f0f4025c5d6a81c1b64f711e066756 (patch)
tree3db882e191862e4c24e5653167a756145b567759 /packages/core/src/tools/shell.ts
parent137ffec3f6fe035b7edcb478e6c44e66fa593839 (diff)
Improve Function Call argument validation and typing (#2881)
Co-authored-by: N. Taylor Mullen <[email protected]>
Diffstat (limited to 'packages/core/src/tools/shell.ts')
-rw-r--r--packages/core/src/tools/shell.ts19
1 files changed, 8 insertions, 11 deletions
diff --git a/packages/core/src/tools/shell.ts b/packages/core/src/tools/shell.ts
index bdee190f..c8fa6ba7 100644
--- a/packages/core/src/tools/shell.ts
+++ b/packages/core/src/tools/shell.ts
@@ -16,6 +16,7 @@ import {
ToolExecuteConfirmationDetails,
ToolConfirmationOutcome,
} from './tools.js';
+import { Type } from '@google/genai';
import { SchemaValidator } from '../utils/schemaValidator.js';
import { getErrorMessage } from '../utils/errors.js';
import stripAnsi from 'strip-ansi';
@@ -51,19 +52,19 @@ Signal: Signal number or \`(none)\` if no signal was received.
Background PIDs: List of background processes started or \`(none)\`.
Process Group PGID: Process group started or \`(none)\``,
{
- type: 'object',
+ type: Type.OBJECT,
properties: {
command: {
- type: 'string',
+ type: Type.STRING,
description: 'Exact bash command to execute as `bash -c <command>`',
},
description: {
- type: 'string',
+ type: Type.STRING,
description:
'Brief description of the command for the user. Be specific and concise. Ideally a single sentence. Can be up to 3 sentences for clarity. No line breaks.',
},
directory: {
- type: 'string',
+ type: Type.STRING,
description:
'(OPTIONAL) Directory to run the command in, if not the project root directory. Must be relative to the project root directory and must already exist.',
},
@@ -223,13 +224,9 @@ Process Group PGID: Process group started or \`(none)\``,
}
return commandCheck.reason;
}
- if (
- !SchemaValidator.validate(
- this.parameterSchema as Record<string, unknown>,
- params,
- )
- ) {
- return `Parameters failed schema validation.`;
+ const errors = SchemaValidator.validate(this.schema.parameters, params);
+ if (errors) {
+ return errors;
}
if (!params.command.trim()) {
return 'Command cannot be empty.';