Cogitator
Tools

Built-in Tools

Reference for all 26 built-in tools that ship with @cogitator-ai/core, organized by category.

Overview

Cogitator ships with 26 built-in tools covering math, data processing, file system operations, network, databases, and more. Every tool is type-safe with Zod schemas and returns structured results.

import { builtinTools, calculator, fileRead, httpRequest } from '@cogitator-ai/core';

const agent = new Agent({
  name: 'assistant',
  model: 'openai/gpt-4o',
  tools: builtinTools,
});

You can also pick individual tools instead of loading the full set.


Math & Utilities

calculator

Evaluates mathematical expressions safely without eval. Supports +, -, *, /, ^ (power), parentheses, and functions: sqrt, sin, cos, tan, log, abs, round, floor, ceil. Constants: pi, e.

ParameterTypeDescription
expressionstringMath expression, e.g. "2 + 3 * 4"

uuid

Generates one or more UUID v4 identifiers using Node's crypto.randomUUID.

ParameterTypeDescription
countnumberNumber of UUIDs to generate (1 - 100)

random_number

Generates a random number within a range.

ParameterTypeDescription
minnumberMinimum value (default: 0)
maxnumberMaximum value (default: 1)
integerbooleanReturn integer (default: false)

random_string

Generates a cryptographically secure random string using crypto.randomBytes.

ParameterTypeDescription
lengthnumberString length (1 - 1000)
charsetenumalphanumeric | alpha | numeric | hex

hash

Computes cryptographic hashes. Supports md5, sha1, sha256, sha512.

ParameterTypeDescription
datastringString to hash
algorithmenumHash algorithm (default: sha256)
encodingenumhex | base64 (default: hex)

sleep

Pauses execution for a specified duration. Maximum 60 seconds.

ParameterTypeDescription
msnumberMilliseconds to sleep (0 - 60000)

datetime

Returns the current date and time in various formats and timezones.

ParameterTypeDescription
timezonestringIANA timezone, e.g. "America/New_York"
formatenumiso | unix | readable | date | time

Data Processing

json_parse

Parses a JSON string into an object. Returns { result, valid: true } on success, { error, valid: false } on failure.

ParameterTypeDescription
jsonstringJSON string to parse

json_stringify

Converts a value to a JSON string with optional pretty-printing.

ParameterTypeDescription
dataunknownData to serialize
prettybooleanEnable indentation (default: false)
indentnumberSpaces for indent (0 - 8)

base64_encode / base64_decode

Encode strings to Base64 or decode Base64 back to plain text. Both support URL-safe variants.

ParameterTypeDescription
datastringInput string
urlSafebooleanURL-safe Base64 variant

regex_match

Finds all matches of a regular expression in text, returning match strings, indices, and named groups.

ParameterTypeDescription
textstringText to search
patternstringRegular expression pattern
flagsstringRegex flags (default: "g")

regex_replace

Replaces regex matches in text. Supports $1, $2 capture group references.

ParameterTypeDescription
textstringInput text
patternstringRegex pattern
replacementstringReplacement string
flagsstringRegex flags (default: "g")

File System

All file system tools declare sideEffects: ['filesystem'] where applicable.

file_read

Reads file contents. Use base64 encoding for binary files.

ParameterTypeDescription
pathstringPath to the file
encodingenumutf-8 | base64 (default: utf-8)

file_write

Writes content to a file. Creates parent directories by default.

ParameterTypeDescription
pathstringFile path
contentstringContent to write
encodingenumutf-8 | base64
createDirsbooleanCreate parent dirs (default: true)

file_list

Lists directory contents with file names, paths, types, and sizes.

ParameterTypeDescription
pathstringDirectory path
recursivebooleanRecurse into subdirectories
includeHiddenbooleanInclude dotfiles

file_exists

Checks if a file or directory exists and returns its type and size.

ParameterTypeDescription
pathstringPath to check

file_delete

Deletes a file or directory. Use recursive: true for non-empty directories.

ParameterTypeDescription
pathstringPath to delete
recursivebooleanDelete contents recursively

Network & Web

http_request

Makes HTTP requests with custom headers, body, and timeout. Responses larger than 100 KB are truncated.

ParameterTypeDescription
urlstringRequest URL
methodenumGET | POST | PUT | PATCH | DELETE | HEAD | OPTIONS
headersRecord<string, string>Request headers
bodystringRequest body (for POST/PUT/PATCH)
timeoutnumberTimeout in ms (default: 30000, max: 60000)

Searches the web via Tavily, Brave Search, or Serper APIs. Auto-detects the provider from environment variables (TAVILY_API_KEY, BRAVE_API_KEY, SERPER_API_KEY).

ParameterTypeDescription
querystringSearch query
providerenumtavily | brave | serper
maxResultsnumberMax results (default: 5, max: 20)
searchDepthenumbasic | advanced (Tavily only)
includeAnswerbooleanInclude AI summary (Tavily only)

web_scrape

Fetches and extracts content from web pages. Supports text, markdown, or raw HTML output, CSS selector extraction, and link/image collection.

ParameterTypeDescription
urlstringURL to scrape
selectorstringCSS selector to extract (e.g. "article")
formatenumtext | markdown | html
maxLengthnumberMax content length (default: 50000)
includeLinksbooleanExtract links
includeImagesbooleanExtract image URLs

sql_query

Executes SQL queries against PostgreSQL or SQLite. Supports parameterized queries and read-only mode by default for safety.

ParameterTypeDescription
querystringSQL query
databaseenumpostgres | sqlite (auto-detected)
connectionStringstringConnection string (defaults to DATABASE_URL)
paramsunknown[]Parameterized query values
maxRowsnumberMax rows returned (default: 100, max: 1000)
readOnlybooleanOnly allow SELECT queries (default: true)

Performs semantic similarity search using pgvector. Converts queries to embeddings via OpenAI, Ollama, or Google, then finds similar documents in PostgreSQL.

ParameterTypeDescription
querystringSearch query (converted to embedding)
collectionstringTable name (default: "documents")
topKnumberNumber of results (default: 5)
thresholdnumberMinimum similarity 0-1 (default: 0.7)
filterRecordMetadata filter as key-value pairs
embeddingProviderenumopenai | ollama | google

Communication & Dev

send_email

Sends email via Resend API or SMTP. Supports HTML body, CC/BCC, and reply-to.

ParameterTypeDescription
tostring | string[]Recipient(s)
subjectstringEmail subject
bodystringEmail body (plain text or HTML)
htmlbooleanTreat body as HTML
providerenumresend | smtp (auto-detected)

github_api

Full GitHub API integration. Supports 12 actions: get_repo, list_issues, get_issue, create_issue, update_issue, list_prs, get_pr, create_pr, get_file, list_commits, search_code, search_issues. Requires GITHUB_TOKEN.

const agent = new Agent({
  name: 'github-bot',
  model: 'openai/gpt-4o',
  tools: [githubApi],
  instructions: 'You help manage GitHub repositories.',
});

exec

Executes shell commands. Declares side effects for process, filesystem, and network. Configured with requiresApproval: true and a Docker sandbox by default.

ParameterTypeDescription
commandstringShell command to execute
cwdstringWorking directory
timeoutnumberTimeout in ms (default: 30000, max: 300s)
envRecordAdditional environment variables

On this page