You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
667 B
21 lines
667 B
import { z } from "zod";
|
|
|
|
export const calculatorConfigSchema = z.object({
|
|
maxExpressionLength: z.number().int().positive().max(2000).default(500),
|
|
precision: z.number().int().positive().max(50).default(10),
|
|
});
|
|
|
|
export type CalculatorToolConfig = z.infer<typeof calculatorConfigSchema>;
|
|
|
|
export const DEFAULT_CALCULATOR_CONFIG: CalculatorToolConfig = {
|
|
maxExpressionLength: 500,
|
|
precision: 10,
|
|
};
|
|
|
|
export function parseCalculatorConfig(raw: unknown): CalculatorToolConfig {
|
|
const parsed = calculatorConfigSchema.safeParse(raw);
|
|
if (!parsed.success) {
|
|
throw new Error(`Invalid calculator config: ${parsed.error.message}`);
|
|
}
|
|
return parsed.data;
|
|
}
|
|
|