agent-core / Exports / AbstractTool
Class: AbstractTool<TParameters, TResult>
Abstract base class for tools with type parameter support Provides type-safe parameter handling and result processing
🎯 ARCHITECTURAL PRINCIPLES:
- Pure abstract class - depends only on interfaces
- No concrete class dependencies (EventService interface only)
- Dependency Injection for all external dependencies
- Graceful degradation (undefined dependencies = silent operation)
Type parameters
| Name | Type | Description |
|---|---|---|
TParameters | TToolParameters | Tool parameters type (defaults to TToolParameters) |
TResult | IToolResult | Tool result type (defaults to ToolResult for backward compatibility) |
Implements
IToolWithEventService<TParameters,TResult>
Table of contents
Constructors
Properties
Methods
Constructors
constructor
• new AbstractTool<TParameters, TResult>(options?): AbstractTool<TParameters, TResult>
Constructor with simplified options
🎯 DEPENDENCY INJECTION: All dependencies are injected via options parameter No concrete classes are instantiated within this constructor
Type parameters
| Name | Type |
|---|---|
TParameters | TToolParameters |
TResult | IToolResult |
Parameters
| Name | Type | Description |
|---|---|---|
options | IAbstractToolOptions | Configuration options for the tool |
Returns
AbstractTool<TParameters, TResult>
Defined in
packages/agent-core/src/abstracts/abstract-tool.ts:150
Properties
schema
• Readonly Abstract schema: IToolSchema
Implementation of
Defined in
packages/agent-core/src/abstracts/abstract-tool.ts:128
Methods
setEventService
▸ setEventService(eventService): void
Set EventService for post-construction injection
🎯 DEPENDENCY INJECTION: Accepts EventService as-is without transformation Caller is responsible for providing properly configured EventService
Parameters
| Name | Type | Description |
|---|---|---|
eventService | undefined | IEventService | EventService instance to use for event emission (or undefined for silent operation) |
Returns
void
Implementation of
IToolWithEventService.setEventService
Defined in
packages/agent-core/src/abstracts/abstract-tool.ts:166
execute
▸ execute(parameters, context): Promise<TResult>
Execute tool with simplified lifecycle
Parameters
| Name | Type | Description |
|---|---|---|
parameters | TParameters | Tool parameters |
context | IToolExecutionContext | Optional execution context |
Returns
Promise<TResult>
Promise resolving to tool result
Implementation of
Defined in
packages/agent-core/src/abstracts/abstract-tool.ts:198
validate
▸ validate(parameters): boolean
Parameters
| Name | Type |
|---|---|
parameters | TParameters |
Returns
boolean
Implementation of
IToolWithEventService.validate
Defined in
packages/agent-core/src/abstracts/abstract-tool.ts:215
validateParameters
▸ validateParameters(parameters): IParameterValidationResult
Validate tool parameters with detailed result (default implementation)
Parameters
| Name | Type |
|---|---|
parameters | TParameters |
Returns
Implementation of
IToolWithEventService.validateParameters
Defined in
packages/agent-core/src/abstracts/abstract-tool.ts:225
getDescription
▸ getDescription(): string
Returns
string
Implementation of
IToolWithEventService.getDescription
Defined in
packages/agent-core/src/abstracts/abstract-tool.ts:242
getName
▸ getName(): string
Returns
string