mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-21 01:07:46 +00:00
feat(core): Cleanup after migrating tools. (#6199)
Co-authored-by: Jacob Richman <jacob314@gmail.com>
This commit is contained in:
@@ -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>;
|
||||
|
||||
Reference in New Issue
Block a user