summaryrefslogtreecommitdiff
path: root/packages/core/src/tools/tools.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/core/src/tools/tools.ts')
-rw-r--r--packages/core/src/tools/tools.ts156
1 files changed, 0 insertions, 156 deletions
diff --git a/packages/core/src/tools/tools.ts b/packages/core/src/tools/tools.ts
index ee8b830b..5684e4ac 100644
--- a/packages/core/src/tools/tools.ts
+++ b/packages/core/src/tools/tools.ts
@@ -91,50 +91,6 @@ export abstract class BaseToolInvocation<
export type AnyToolInvocation = ToolInvocation<object, ToolResult>;
/**
- * An adapter that wraps the legacy `Tool` interface to make it compatible
- * with the new `ToolInvocation` pattern.
- */
-export class LegacyToolInvocation<
- TParams extends object,
- TResult extends ToolResult,
-> implements ToolInvocation<TParams, TResult>
-{
- constructor(
- private readonly legacyTool: BaseTool<TParams, TResult>,
- readonly params: TParams,
- ) {}
-
- getDescription(): string {
- return this.legacyTool.getDescription(this.params);
- }
-
- toolLocations(): ToolLocation[] {
- return this.legacyTool.toolLocations(this.params);
- }
-
- shouldConfirmExecute(
- abortSignal: AbortSignal,
- ): Promise<ToolCallConfirmationDetails | false> {
- return this.legacyTool.shouldConfirmExecute(this.params, abortSignal);
- }
-
- execute(
- signal: AbortSignal,
- updateOutput?: (output: string) => void,
- terminalColumns?: number,
- terminalRows?: number,
- ): Promise<TResult> {
- return this.legacyTool.execute(
- this.params,
- signal,
- updateOutput,
- terminalColumns,
- terminalRows,
- );
- }
-}
-
-/**
* Interface for a tool builder that validates parameters and creates invocations.
*/
export interface ToolBuilder<
@@ -285,118 +241,6 @@ export abstract class BaseDeclarativeTool<
*/
export type AnyDeclarativeTool = DeclarativeTool<object, ToolResult>;
-/**
- * Base implementation for tools with common functionality
- * @deprecated Use `DeclarativeTool` for new tools.
- */
-export abstract class BaseTool<
- TParams extends object,
- TResult extends ToolResult = ToolResult,
-> extends DeclarativeTool<TParams, TResult> {
- /**
- * Creates a new instance of BaseTool
- * @param name Internal name of the tool (used for API calls)
- * @param displayName User-friendly display name of the tool
- * @param description Description of what the tool does
- * @param isOutputMarkdown Whether the tool's output should be rendered as markdown
- * @param canUpdateOutput Whether the tool supports live (streaming) output
- * @param parameterSchema JSON Schema defining the parameters
- */
- constructor(
- override readonly name: string,
- override readonly displayName: string,
- override readonly description: string,
- override readonly kind: Kind,
- override readonly parameterSchema: unknown,
- override readonly isOutputMarkdown: boolean = true,
- override readonly canUpdateOutput: boolean = false,
- ) {
- super(
- name,
- displayName,
- description,
- kind,
- parameterSchema,
- isOutputMarkdown,
- canUpdateOutput,
- );
- }
-
- build(params: TParams): ToolInvocation<TParams, TResult> {
- const validationError = this.validateToolParams(params);
- if (validationError) {
- throw new Error(validationError);
- }
- return new LegacyToolInvocation(this, params);
- }
-
- /**
- * Validates the parameters for the tool
- * 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
- * @returns An error message string if invalid, null otherwise
- */
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
- override validateToolParams(params: TParams): string | null {
- // Implementation would typically use a JSON Schema validator
- // This is a placeholder that should be implemented by derived classes
- return null;
- }
-
- /**
- * Gets a pre-execution description of the tool operation
- * Default implementation that should be overridden by derived classes
- * @param params Parameters for the tool execution
- * @returns A markdown string describing what the tool will do
- */
- getDescription(params: TParams): string {
- return JSON.stringify(params);
- }
-
- /**
- * Determines if the tool should prompt for confirmation before execution
- * @param params Parameters for the tool execution
- * @returns Whether or not execute should be confirmed by the user.
- */
- shouldConfirmExecute(
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
- params: TParams,
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
- abortSignal: AbortSignal,
- ): Promise<ToolCallConfirmationDetails | false> {
- return Promise.resolve(false);
- }
-
- /**
- * Determines what file system paths the tool will affect
- * @param params Parameters for the tool execution
- * @returns A list of such paths
- */
- toolLocations(
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
- params: TParams,
- ): ToolLocation[] {
- return [];
- }
-
- /**
- * Abstract method to execute the tool with the given parameters
- * Must be implemented by derived classes
- * @param params Parameters for the tool execution
- * @param signal AbortSignal for tool cancellation
- * @returns Result of the tool execution
- */
- abstract execute(
- params: TParams,
- signal: AbortSignal,
- updateOutput?: (output: string) => void,
- terminalColumns?: number,
- terminalRows?: number,
- ): Promise<TResult>;
-}
-
export interface ToolResult {
/**
* A short, one-line summary of the tool's action and result.