fix: add type validation for tool parameters (#45)

Co-authored-by: Letta <noreply@letta.com>
This commit is contained in:
Charles Packer
2025-10-31 14:47:07 -07:00
committed by GitHub
parent b54b30af14
commit af5a2fa68a
4 changed files with 319 additions and 1 deletions

View File

@@ -1,7 +1,8 @@
import { readdir, stat } from "node:fs/promises";
import { join, resolve } from "node:path";
import picomatch from "picomatch";
import { validateRequiredParams } from "./validation.js";
import LSSchema from "../schemas/LS.json";
import { validateParamTypes, validateRequiredParams } from "./validation.js";
interface LSArgs {
path: string;
@@ -17,6 +18,7 @@ export async function ls(
args: LSArgs,
): Promise<{ content: Array<{ type: string; text: string }> }> {
validateRequiredParams(args, ["path"], "LS");
validateParamTypes(args, LSSchema, "LS");
const { path: inputPath, ignore = [] } = args;
const dirPath = resolve(inputPath);
try {