Class: OpenApiTool<TParams, TResult>
OpenAPI schema-based tool class
OpenApiTool
Description
Tool that uses OpenAPI specification schema format for parameter definition.
Example
import { OpenApiTool } from '@robota-sdk/tools';
const apiTool = new OpenApiTool({
name: 'userInfo',
description: 'Get user information by ID',
category: 'api',
parameters: {
type: 'object',
properties: {
userId: {
type: 'string',
description: 'Unique user identifier'
},
includeProfile: {
type: 'boolean',
description: 'Whether to include detailed profile information',
default: false
}
},
required: ['userId']
},
execute: async (params) => {
// API call logic
const userInfo = { id: params.userId, name: 'John Doe' };
return {
status: 'success',
data: userInfo
};
}
});
Type parameters
Name | Type | Description |
---|---|---|
TParams | any | Tool parameter type |
TResult | any | Tool result type |
Hierarchy
BaseTool
<TParams
,TResult
>↳
OpenApiTool
Table of contents
Constructors
Properties
Accessors
Methods
Constructors
constructor
• new OpenApiTool<TParams
, TResult
>(options
): OpenApiTool
<TParams
, TResult
>
Constructor
Type parameters
Name | Type |
---|---|
TParams | any |
TResult | any |
Parameters
Name | Type | Description |
---|---|---|
options | OpenApiToolOptions <TParams , TResult > | OpenAPI tool options |
Returns
OpenApiTool
<TParams
, TResult
>
Overrides
Defined in
packages/tools/src/tool/openapi-tool.ts:69
Properties
name
• Readonly
name: string
Tool name
Inherited from
Defined in
packages/tools/src/tool/base-tool.ts:29
description
• Readonly
description: string
Tool description
Inherited from
Defined in
packages/tools/src/tool/base-tool.ts:34
category
• Optional
Readonly
category: string
Tool category
Inherited from
Defined in
packages/tools/src/tool/base-tool.ts:39
version
• Optional
Readonly
version: string
Tool version
Inherited from
Defined in
packages/tools/src/tool/base-tool.ts:44
Accessors
schema
• get
schema(): Object
Tool schema (returns OpenAPI schema)
Returns
Object
OpenAPI schema
Name | Type |
---|---|
type | "object" |
properties | Record <string , { type : string ; description? : string ; enum? : any [] ; default? : any }> |
required? | string [] |
Overrides
BaseTool.schema
Defined in
packages/tools/src/tool/openapi-tool.ts:79
Methods
execute
▸ execute(params
): Promise
<ToolResult
<TResult
>>
Execute tool
Parameters
Name | Type | Description |
---|---|---|
params | TParams | Tool parameters |
Returns
Promise
<ToolResult
<TResult
>>
Tool execution result
Inherited from
Defined in
packages/tools/src/tool/base-tool.ts:108
toFunctionSchema
▸ toFunctionSchema(): FunctionSchema
Convert to function schema
Returns
Function schema
Inherited from
Defined in
packages/tools/src/tool/base-tool.ts:145
toFunctionDefinition
▸ toFunctionDefinition(): FunctionDefinition
Convert to function definition
Returns
Function definition
Inherited from
Defined in
packages/tools/src/tool/base-tool.ts:158
toString
▸ toString(): string
Generate string representation
Returns
string
String representation of the tool
Inherited from
Defined in
packages/tools/src/tool/base-tool.ts:171
create
▸ create<TParams
, TResult
>(options
): OpenApiTool
<TParams
, TResult
>
OpenAPI tool creation helper method
Type parameters
Name | Type |
---|---|
TParams | any |
TResult | any |
Parameters
Name | Type | Description |
---|---|---|
options | OpenApiToolOptions <TParams , TResult > | OpenAPI tool options |
Returns
OpenApiTool
<TParams
, TResult
>
OpenApiTool instance