Creates a new tool configuration
Initializes a tool that extends agent capabilities through external integrations. Tools provide a standardized interface for agents to interact with external services and process data.
Configuration data including: - name: Tool identifier - friendly_name: Display name - short_description: Brief description - tool_schema: JSON Schema for inputs - required_environment_variables: Required env vars - source_url: Integration endpoint - metadata: Additional tool data
Optionaluri: stringOptional custom URI path for the tool endpoint
Basic file processor:
const fileTool = new Tool({
name: 'file-processor',
friendly_name: 'File Processor',
short_description: 'Process and transform files',
tool_schema: JSON.stringify({
type: 'object',
properties: {
file_path: {
type: 'string',
description: 'Path to input file'
},
output_format: {
type: 'string',
enum: ['json', 'csv', 'xml'],
default: 'json'
}
},
required: ['file_path']
})
});
API integration:
const apiTool = new Tool({
name: 'api-client',
friendly_name: 'API Integration',
short_description: 'Make API requests',
tool_schema: JSON.stringify({
type: 'object',
properties: {
method: {
type: 'string',
enum: ['GET', 'POST', 'PUT', 'DELETE']
},
endpoint: {
type: 'string',
pattern: '^/'
},
headers: {
type: 'object',
additionalProperties: true
},
body: {
type: 'object',
additionalProperties: true
}
},
required: ['method', 'endpoint']
}),
required_environment_variables: [
'API_KEY',
'API_SECRET'
],
source_url: 'https://api.service.com',
metadata: {
version: '1.0',
rate_limit: 100,
timeout: 5000
}
}, '/integrations/tool');
Get the image functionality for this tool
This getter provides access to the tool's image operations through the Image class. It allows for image uploads and other image-related operations specific to this tool.
A new Image instance configured for this tool
Check if the entity is active
This method checks the active status of the entity. Most entities in the system can be active or inactive, which affects their availability and usability in the platform.
True if the entity is active, false otherwise
Convert model instance to interface data
This method serializes the model instance to a plain object that matches the interface type. This is useful for:
The model data as a plain object matching the interface type
Convert model instance to API payload
This method creates a payload suitable for API requests by:
A clean object suitable for API requests
Update model data with new values
This method updates the model's data and instance properties with new values. It performs a shallow merge of the updates with existing data, allowing for partial updates of the model's properties.
Object containing properties to update
const user = new User({
email: 'old@example.com',
firstName: 'John'
});
// Update multiple properties
user.update({
email: 'new@example.com',
lastName: 'Doe'
});
// Save changes to API
await user.save();
This method only updates the local model instance. To persist changes to the API, call save after updating.
Save the model instance to the API
This method persists the current state of the model to the API using a PUT request. It requires the model to have an ID (existing instance). For new instances, use the collection's create method instead.
The method:
Promise resolving to the updated model data
Delete the model instance from the API
This method permanently deletes the model instance from the API and clears the local data. This operation cannot be undone.
The method:
Promise that resolves when deletion is successful
Like or unlike this tool
Toggles the like status of this tool. If the tool is already liked, it will be unliked, and vice versa.
Promise that resolves to the updated tool instance
Tool class for managing agent capabilities
This class represents an external integration or utility that extends agent capabilities in the Mosaia platform. Tools enable agents to interact with external services, process data, and perform specialized tasks through well-defined interfaces.
Features:
Remarks
Tools provide:
Common tool types:
Example
Basic API tool:
Example
Database tool: