Skip to content
1 min read · 99 words

Variable: calculateTool ​

ts
const calculateTool: Tool<SpooledArtifact>;

Defined in: src/batteries/tools/math/index.ts:546

Evaluates a mathjs-syntax expression and returns the numeric result alongside the KaTeX representation of the parsed expression.

Remarks ​

Supports arithmetic, trigonometric, logarithmic, exponential, factorial, matrix, and unit operations via mathjs. The mathjs instance is hardened: dangerous functions (import, createUnit, simplify, derivative, compile, chain, reviver, replacer) are disabled to prevent interpreter-surface exposure.

Expressions over 1000 characters are rejected with an error string (not thrown). Parse and evaluation errors are also returned as error strings — the tool surfaces math errors as content rather than exceptions, so the model can react to them in-line.