diff options
| author | joshualitt <[email protected]> | 2025-08-07 10:05:37 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-08-07 17:05:37 +0000 |
| commit | 8bac9e7d048c7ff97f0942b23edb0167ee6ca83e (patch) | |
| tree | c1a4d73348256a152e7c3dad2bbd89979a2ca30d /packages/core/src/tools/tools.ts | |
| parent | 0d65baf9283138da56cdf08b00058ab3cf8cbaf9 (diff) | |
Migrate EditTool, GrepTool, and GlobTool to DeclarativeTool (#5744)
Diffstat (limited to 'packages/core/src/tools/tools.ts')
| -rw-r--r-- | packages/core/src/tools/tools.ts | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/packages/core/src/tools/tools.ts b/packages/core/src/tools/tools.ts index 79e6f010..ceacd6ca 100644 --- a/packages/core/src/tools/tools.ts +++ b/packages/core/src/tools/tools.ts @@ -54,6 +54,34 @@ export interface ToolInvocation< } /** + * 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. */ export type AnyToolInvocation = ToolInvocation<object, ToolResult>; |
