@braingrid/tools
v1.1.0
Published
Reusable tool ecosystem for AI agents
Downloads
125
Readme
@braingrid/tools
Reusable tool ecosystem for AI agents.
Installation
pnpm add @braingrid/tools aiTools
getCurrentTime
Get current date and time with timezone support.
import { getCurrentTime } from '@braingrid/tools';
const agent = createAgent({
agentType: 'assistant',
tools: { getCurrentTime },
});webSearch
Search the web using configurable providers.
import { webSearch, configureWebSearch, ExaSearchProvider } from '@braingrid/tools';
// Configure search provider
configureWebSearch(new ExaSearchProvider(process.env.EXA_API_KEY));
const agent = createAgent({
agentType: 'research',
tools: { webSearch },
});calculate
Perform safe mathematical calculations using mathjs in sandboxed mode.
Security: Uses mathjs library for secure evaluation. No access to Node.js globals, file system, or network. Includes comprehensive security testing against RCE attacks.
Supported:
- Arithmetic:
+,-,*,/,%,^(exponentiation) - Functions:
sqrt,abs,round,floor,ceil,min,max,pow,sin,cos,tan,log,exp - Constants:
pi,e
import { calculate } from '@braingrid/tools';
const agent = createAgent({
agentType: 'assistant',
tools: { calculate },
});
// Direct usage
const result = executeCalculate({ expression: '2 ^ 8' });
console.log(result.result); // 256
const result2 = executeCalculate({ expression: 'sqrt(16) + pi' });
console.log(result2.result); // 7.14159...formatText
Format text with various transformations.
import { formatText } from '@braingrid/tools';
const agent = createAgent({
agentType: 'assistant',
tools: { formatText },
});Custom Tools
Create your own tools using the AI SDK's tool() function:
import { tool } from 'ai';
import { z } from 'zod';
export const myCustomTool = tool({
description: 'Description of what this tool does',
inputSchema: z.object({
param: z.string(),
}),
execute: async ({ param }) => {
// Your implementation
return { result: 'success' };
},
});License
Apache-2.0
