Skip to main content

DeclarativeTool

@codebolt/codeboltjs


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

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

ParameterTypeDefault value
namestringundefined
displayNamestringundefined
descriptionstringundefined
kindKindundefined
parameterSchemaunknownundefined
isOutputMarkdownbooleantrue
canUpdateOutputbooleanfalse

Returns

DeclarativeTool<TParams, TResult>

Properties

PropertyModifierTypeDefault valueDescriptionDefined in
canUpdateOutputreadonlybooleanfalseWhether the tool supports live (streaming) outputpackages/codeboltjs/src/tools/base-tool.ts:69
descriptionreadonlystringundefinedDescription of what the tool doespackages/codeboltjs/src/tools/base-tool.ts:65
displayNamereadonlystringundefinedThe user-friendly display name of the toolpackages/codeboltjs/src/tools/base-tool.ts:64
isOutputMarkdownreadonlybooleantrueWhether the tool's output should be rendered as markdownpackages/codeboltjs/src/tools/base-tool.ts:68
kindreadonlyKindundefinedThe kind of tool for categorization and permissionspackages/codeboltjs/src/tools/base-tool.ts:66
namereadonlystringundefinedThe internal name of the tool (used for API calls)packages/codeboltjs/src/tools/base-tool.ts:63
parameterSchemareadonlyunknownundefined-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

ToolBuilder.explanation


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

ToolBuilder.genAISchema


openAIFunctionCall

Get Signature

get openAIFunctionCall(): OpenAIFunctionCall;

Defined in: packages/codeboltjs/src/tools/base-tool.ts:102

Get OpenAI function call format

Returns

OpenAIFunctionCall


schema

Get Signature

get schema(): OpenAIToolSchema;

Defined in: packages/codeboltjs/src/tools/base-tool.ts:83

Primary schema format (OpenAI tool schema)

Returns

OpenAIToolSchema

Primary schema format (OpenAI tool schema)

Implementation of

ToolBuilder.schema

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

ParameterType
paramsTParams

Returns

ToolInvocation<TParams, TResult>

Implementation of

ToolBuilder.build


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

ParameterType
paramsTParams
signalAbortSignal
updateOutput?(output: string) => void

Returns

Promise<TResult>

Implementation of

ToolBuilder.buildAndExecute


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

ParameterType
paramsTParams
abortSignalAbortSignal

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

ParameterType
_paramsTParams

Returns

string | null

Implementation of

ToolBuilder.validateToolParams