Migrate EditTool, GrepTool, and GlobTool to DeclarativeTool (#5744)

This commit is contained in:
joshualitt
2025-08-07 10:05:37 -07:00
committed by GitHub
parent 0d65baf928
commit 8bac9e7d04
8 changed files with 649 additions and 563 deletions

View File

@@ -53,6 +53,34 @@ export interface ToolInvocation<
): Promise<TResult>;
}
/**
* A convenience base class for ToolInvocation.
*/
export abstract class BaseToolInvocation<
TParams extends object,
TResult extends ToolResult,
> implements ToolInvocation<TParams, TResult>
{
constructor(readonly params: TParams) {}
abstract getDescription(): string;
toolLocations(): ToolLocation[] {
return [];
}
shouldConfirmExecute(
_abortSignal: AbortSignal,
): Promise<ToolCallConfirmationDetails | false> {
return Promise.resolve(false);
}
abstract execute(
signal: AbortSignal,
updateOutput?: (output: string) => void,
): Promise<TResult>;
}
/**
* A type alias for a tool invocation where the specific parameter and result types are not known.
*/