mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-19 09:33:53 +00:00
don't confirm invalid params in terminal tool, or in general (added comments to base class) (#187)
This commit is contained in:
@@ -244,6 +244,9 @@ Use this tool for running build steps (\`npm install\`, \`make\`), linters (\`es
|
|||||||
async shouldConfirmExecute(
|
async shouldConfirmExecute(
|
||||||
params: TerminalToolParams,
|
params: TerminalToolParams,
|
||||||
): Promise<ToolCallConfirmationDetails | false> {
|
): Promise<ToolCallConfirmationDetails | false> {
|
||||||
|
if (this.validateToolParams(params)) {
|
||||||
|
return false; // skip confirmation, execute call will fail immediately
|
||||||
|
}
|
||||||
const rootCommand =
|
const rootCommand =
|
||||||
params.command
|
params.command
|
||||||
.trim()
|
.trim()
|
||||||
|
|||||||
@@ -36,6 +36,8 @@ export interface Tool<
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Validates the parameters for the 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
|
* @param params Parameters to validate
|
||||||
* @returns An error message string if invalid, null otherwise
|
* @returns An error message string if invalid, null otherwise
|
||||||
*/
|
*/
|
||||||
@@ -102,6 +104,8 @@ export abstract class BaseTool<
|
|||||||
/**
|
/**
|
||||||
* Validates the parameters for the tool
|
* Validates the parameters for the tool
|
||||||
* This is a placeholder implementation and should be overridden
|
* 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
|
* @param params Parameters to validate
|
||||||
* @returns An error message string if invalid, null otherwise
|
* @returns An error message string if invalid, null otherwise
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user