import z from 'zod';
const parameters = z.object({
    path: z.string().describe('The path to the file to read.'),
});
export const readFileTool = {
    name: 'sys:read_file',
    description: 'Read the content of a file at the specified path',
    parameters,
    async execute(rawArgs) {
        if (!window.filesystem?.readFile) {
            throw new Error('filesystem bridge is not available');
        }
        const args = parameters.parse(rawArgs);
        const content = await window.filesystem.readFile(args.path);
        const previewLimit = 500;
        const contentPreview = content.length > previewLimit
            ? `${content.slice(0, previewLimit)}…`
            : content;
        return JSON.stringify({
            path: args.path,
            content: contentPreview,
        });
    },
};
