shipfastlabs/toolkit-calculator

Calculator tool for the Laravel AI SDK

Maintainers

Package info

github.com/shipfastlabs/toolkit-calculator

pkg:composer/shipfastlabs/toolkit-calculator

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

1.0.0 2026-05-31 18:17 UTC

This package is auto-updated.

Last update: 2026-05-31 19:30:03 UTC


README

Latest Version Total Downloads

Calculator tool for the Laravel AI SDK

Part of the shipfastlabs/toolkit catalog of reusable AI tools for the Laravel AI SDK.

Installation

composer require shipfastlabs/toolkit-calculator

Usage

Add the tool to an agent's tools():

use Shipfastlabs\Toolkit\Calculator\CalculatorTool;

$tools = [new CalculatorTool];

Input schema

Parameter Type Required Description
expression string yes The mathematical expression to evaluate, e.g. "3 * (4 + 1)".

Supports +, -, *, /, %, ^ (exponent, right-associative), parentheses, unary +/- and decimal numbers.

Configuration

None. The calculator is pure and ships no config or service provider.

Safety

The expression is parsed by a small recursive-descent evaluator; PHP's eval() is never used. Invalid input, division/modulo by zero and non-finite results are returned to the model as plain strings rather than thrown, so the model can recover.