DeclarativeTool
Abstract Class: DeclarativeTool<TParams, TResult>
Defined in: packages/codeboltjs/src/tools/base-tool.ts:58
Base class for tools that separates validation from execution
Extended by
Type Parameters
| Type Parameter |
|---|
TParams extends object |
TResult extends ToolFrameworkResult |
Implements
ToolBuilder<TParams,TResult>
Constructors
Constructor
new DeclarativeTool<TParams, TResult>(
name: string,
displayName: string,
description: string,
kind: Kind,
parameterSchema: unknown,
isOutputMarkdown: boolean,
canUpdateOutput: boolean): DeclarativeTool<TParams, TResult>;
Defined in: packages/codeboltjs/src/tools/base-tool.ts:62
Parameters
| Parameter | Type | Default value |
|---|---|---|
name | string | undefined |
displayName | string | undefined |
description | string | undefined |
kind | Kind | undefined |
parameterSchema | unknown | undefined |
isOutputMarkdown | boolean | true |
canUpdateOutput | boolean | false |
Returns
DeclarativeTool<TParams, TResult>
Properties
| Property | Modifier | Type | Default value | Description | Defined in |
|---|---|---|---|---|---|
canUpdateOutput | readonly | boolean | false | Whether the tool supports live (streaming) output | packages/codeboltjs/src/tools/base-tool.ts:69 |
description | readonly | string | undefined | Description of what the tool does | packages/codeboltjs/src/tools/base-tool.ts:65 |
displayName | readonly | string | undefined | The user-friendly display name of the tool | packages/codeboltjs/src/tools/base-tool.ts:64 |
isOutputMarkdown | readonly | boolean | true | Whether the tool's output should be rendered as markdown | packages/codeboltjs/src/tools/base-tool.ts:68 |
kind | readonly | Kind | undefined | The kind of tool for categorization and permissions | packages/codeboltjs/src/tools/base-tool.ts:66 |
name | readonly | string | undefined | The internal name of the tool (used for API calls) | packages/codeboltjs/src/tools/base-tool.ts:63 |
parameterSchema | readonly | unknown | undefined | - | packages/codeboltjs/src/tools/base-tool.ts:67 |
Accessors
explanation
Get Signature
get explanation(): string;
Defined in: packages/codeboltjs/src/tools/base-tool.ts:76
One sentence explanation as to why this tool is being used, and how it contributes to the goal. Defaults to description if not implemented by subclass.
Returns
string
One sentence explanation as to why this tool is being used, and how it contributes to the goal.
Implementation of
genAISchema
Get Signature
get genAISchema(): FunctionDeclaration;
Defined in: packages/codeboltjs/src/tools/base-tool.ts:118
Get Google GenAI schema format (for backward compatibility)
Returns
FunctionDeclaration
Function declaration schema for Google GenAI (for backward compatibility)
Implementation of
openAIFunctionCall
Get Signature
get openAIFunctionCall(): OpenAIFunctionCall;
Defined in: packages/codeboltjs/src/tools/base-tool.ts:102
Get OpenAI function call format
Returns
schema
Get Signature
get schema(): OpenAIToolSchema;
Defined in: packages/codeboltjs/src/tools/base-tool.ts:83
Primary schema format (OpenAI tool schema)
Returns
Primary schema format (OpenAI tool schema)
Implementation of
Methods
build()
abstract build(params: TParams): ToolInvocation<TParams, TResult>;
Defined in: packages/codeboltjs/src/tools/base-tool.ts:140
The core of the pattern. It validates parameters and, if successful,
returns a ToolInvocation object that encapsulates the logic for the
specific, validated call.
Parameters
| Parameter | Type |
|---|---|
params | TParams |
Returns
ToolInvocation<TParams, TResult>
Implementation of
buildAndExecute()
buildAndExecute(
params: TParams,
signal: AbortSignal,
updateOutput?: (output: string) => void): Promise<TResult>;
Defined in: packages/codeboltjs/src/tools/base-tool.ts:145
A convenience method that builds and executes the tool in one step.
Parameters
| Parameter | Type |
|---|---|
params | TParams |
signal | AbortSignal |
updateOutput? | (output: string) => void |
Returns
Promise<TResult>
Implementation of
validateBuildAndExecute()
validateBuildAndExecute(params: TParams, abortSignal: AbortSignal): Promise<ToolFrameworkResult>;
Defined in: packages/codeboltjs/src/tools/base-tool.ts:174
A convenience method that builds and executes the tool in one step. Never throws.
Parameters
| Parameter | Type |
|---|---|
params | TParams |
abortSignal | AbortSignal |
Returns
Promise<ToolFrameworkResult>
Implementation of
ToolBuilder.validateBuildAndExecute
validateToolParams()
validateToolParams(_params: TParams): string | null;
Defined in: packages/codeboltjs/src/tools/base-tool.ts:131
Validates the raw tool parameters. Subclasses should override this to add custom validation logic beyond the JSON schema check.
Parameters
| Parameter | Type |
|---|---|
_params | TParams |
Returns
string | null