Tools Reference
Code & Computation
Execute code, transform data structures, and perform regex operations.
code_execute Premium
Execute JavaScript code in a secure sandbox environment. The sandbox provides access to Math, JSON, Date, and standard JavaScript built-ins but no filesystem or network access.
TypeScript
tools.codeExecuteParameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| code | string | ✓ | JavaScript code to execute |
| timeout | number | — | Execution timeout in ms (default: 5000) |
Sandbox Environment
- Available:
Math,JSON,Date,Array,Object,String,Number,RegExp,Map,Set,Promise,console.log - Not available:
fetch,require,import,fs,process,eval(nested)
Returns
TypeScript
{
result: "The return value of the last expression",
console: ["Any console.log output"],
executionTimeMs: 12
}Example
TypeScript
// Tool call:
{
name: "code_execute",
args: {
code: `
const data = [10, 20, 30, 40, 50];
const sum = data.reduce((a, b) => a + b, 0);
const avg = sum / data.length;
({ sum, avg, max: Math.max(...data) })
`
}
}
// Result: { sum: 150, avg: 30, max: 50 }data_transform Standard
Transform data structures — reshape, map, flatten, or convert between formats.
TypeScript
tools.dataTransformParameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| data | any | ✓ | Input data to transform |
| operation | string | ✓ | Transform operation (map, flatten, reshape, pivot, etc.) |
| params | object | — | Operation-specific settings |
regex Standard
Perform regular expression operations: match, extract, replace, or split.
TypeScript
tools.regexParameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| text | string | ✓ | Input text to process |
| pattern | string | ✓ | Regular expression pattern |
| operation | string | ✓ | match, extract, replace, or split |
| replacement | string | — | Replacement string (for replace op) |
| flags | string | — | Regex flags: g, i, m, etc. |
Operations
- match — Test if pattern matches, returns boolean + match data
- extract — Extract all matches or capture groups
- replace — Replace matches with replacement string
- split — Split text by pattern
Example
TypeScript
// Extract all email addresses from text
{
name: "regex",
args: {
text: "Contact us at info@skillswarm.com or support@skillswarm.com",
pattern: "[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}",
operation: "extract",
flags: "g"
}
}
// Result: ["info@skillswarm.com", "support@skillswarm.com"]