diff options
| author | Olcan <[email protected]> | 2025-04-27 10:25:12 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-04-27 10:25:12 -0700 |
| commit | 9de2e82b8f9547149d5940dd2c65ea2a6458db3f (patch) | |
| tree | ef8edf230d4e0d11fd6ddea69e5847d131b076cb /packages/server | |
| parent | 7828e813a81778d9eda1942af9c9eedf09e56f4e (diff) | |
don't confirm invalid params in terminal tool, or in general (added comments to base class) (#187)
Diffstat (limited to 'packages/server')
| -rw-r--r-- | packages/server/src/tools/terminal.ts | 3 | ||||
| -rw-r--r-- | packages/server/src/tools/tools.ts | 4 |
2 files changed, 7 insertions, 0 deletions
diff --git a/packages/server/src/tools/terminal.ts b/packages/server/src/tools/terminal.ts index 64b8e652..514ad682 100644 --- a/packages/server/src/tools/terminal.ts +++ b/packages/server/src/tools/terminal.ts @@ -244,6 +244,9 @@ Use this tool for running build steps (\`npm install\`, \`make\`), linters (\`es async shouldConfirmExecute( params: TerminalToolParams, ): Promise<ToolCallConfirmationDetails | false> { + if (this.validateToolParams(params)) { + return false; // skip confirmation, execute call will fail immediately + } const rootCommand = params.command .trim() diff --git a/packages/server/src/tools/tools.ts b/packages/server/src/tools/tools.ts index 448ea206..57a388d8 100644 --- a/packages/server/src/tools/tools.ts +++ b/packages/server/src/tools/tools.ts @@ -36,6 +36,8 @@ export interface Tool< /** * Validates the parameters for the tool + * Should be called from both `shouldConfirmExecute` and `execute` + * `shouldConfirmExecute` should return false immediately if invalid * @param params Parameters to validate * @returns An error message string if invalid, null otherwise */ @@ -102,6 +104,8 @@ export abstract class BaseTool< /** * Validates the parameters for the tool * This is a placeholder implementation and should be overridden + * Should be called from both `shouldConfirmExecute` and `execute` + * `shouldConfirmExecute` should return false immediately if invalid * @param params Parameters to validate * @returns An error message string if invalid, null otherwise */ |
