diff options
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>; |
