Files
Danny AvilaandGitHub d259dfdf0d chore: Update TypeScript/ESLint configs, Check Circular Dependencies, Sort imports, Bump Node Engine, Test Sharding (#226)
* fix: Update import path for isGoogleLike utility in stream.ts due to circular dependency

* ci: add circular dependency check to CI workflow

* feat: add import sorting script and update ESLint config to include scripts/**/*.ts

- Introduced a new script to sort imports in TypeScript files according to project conventions.
- Updated ESLint configuration to include TypeScript files in the scripts directory for linting.
- Added new commands in package.json for sorting imports and checking import order.

* chore: sort imports

* chore: update TypeScript configuration for scripts and ESLint

- Added a new tsconfig.json for the scripts directory, extending the main tsconfig.json.
- Updated ESLint configuration to include the new scripts tsconfig for linting.
- Modified main tsconfig.json to specify types for node and jest, and adjusted included files.

* chore: update Node.js version and ESLint configuration

- Added .nvmrc file to specify Node.js version 24.
- Updated ESLint configuration to disable specific rules for test files.
- Modified package.json to require Node.js version 24 and updated @types/node dependency.
- Adjusted CI and publish workflows to use Node.js version 24.
- Enhanced tsconfig-paths-bootstrap.mjs for better baseUrl handling.
- Refactored logging.ts to improve type safety in write methods.

* chore: remove unused inline attachment mime types from attachments.ts

- Deleted the SUPPORTED_ATTACHMENT_MIMES constant, which included image and PDF mime types.
- This change simplifies the attachment handling by relying solely on SUPPORTED_IMAGE_MIMES.

* chore: update ESLint configuration to enforce no-nested-ternary rule as error

- Changed the severity of the "no-nested-ternary" rule from warning to error in the ESLint configuration, promoting stricter code quality standards.

* refactor: enhance workspace policy hook and improve Cloudflare execution engine

- Updated the `createWorkspacePolicyHook` to introduce a `resolvePolicy` function for clearer policy resolution based on tool names.
- Modified the `CloudflareSandboxExecutionEngine` to use a function for checking if the state is closed, preventing potential issues with concurrent mutations.
- Simplified promise handling in `LocalCodingTools` by removing unnecessary checks and added a new utility function for formatting fallback grep display.

* chore: update import sorting script to use Node instead of Bun

- Changed the shebang in `sort-imports.ts` from Bun to Node for better compatibility.
- Updated `package.json` scripts to reflect the change in runtime for sorting imports.
- Removed Bun types from `tsconfig.json` to streamline type definitions.
- Adjusted the import sorting logic to improve handling of file paths and sorting criteria.

* ci: refactor CI workflow to introduce unit and integration test jobs

- Renamed the existing test job to unit-tests and added a matrix strategy for sharding.
- Created a new integration-tests job for change-gated integration testing.
- Updated test execution commands to accommodate sharding in unit tests.

* ci: enhance CI workflow with summarization tests and environment variables

- Added a new job for summarization tests to the CI workflow.
- Updated the unit test command to exclude an additional test file.
- Introduced environment variables for various API keys to support the new summarization tests.
2026-06-06 11:53:22 -04:00

47 lines
1.1 KiB
TypeScript

import * as math from 'mathjs';
import { Tool } from '@langchain/core/tools';
export const CalculatorToolName = 'calculator';
export const CalculatorToolDescription =
'Useful for getting the result of a math expression. The input to this tool should be a valid mathematical expression that could be executed by a simple calculator.';
export const CalculatorSchema = {
type: 'object',
properties: {
input: {
type: 'string',
description: 'A valid mathematical expression to evaluate',
},
},
required: ['input'],
} as const;
export const CalculatorToolDefinition = {
name: CalculatorToolName,
description: CalculatorToolDescription,
schema: CalculatorSchema,
} as const;
export class Calculator extends Tool {
static lc_name(): string {
return 'Calculator';
}
get lc_namespace(): string[] {
return [...super.lc_namespace, 'calculator'];
}
name = CalculatorToolName;
async _call(input: string): Promise<string> {
try {
return math.evaluate(input).toString();
} catch {
return 'I don\'t know how to do that.';
}
}
description = CalculatorToolDescription;
}