"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.register = register;
const zod_1 = require("zod");
function register(server, mgr) {
    server.registerTool('notes_remove_attachment', {
        description: 'Remove an attachment from a note. The file is deleted from disk.',
        inputSchema: {
            noteId: zod_1.z.string().min(1).max(500).describe('ID of the note'),
            filename: zod_1.z.string().min(1).max(255)
                .refine(s => !/[/\\]/.test(s), 'Filename must not contain path separators')
                .refine(s => !s.includes('..'), 'Filename must not contain ..')
                .refine(s => !s.includes('\0'), 'Filename must not contain null bytes')
                .describe('Filename of the attachment to remove'),
        },
    }, async ({ noteId, filename }) => {
        const ok = mgr.removeAttachment(noteId, filename);
        if (!ok) {
            return { content: [{ type: 'text', text: JSON.stringify({ error: 'Attachment not found' }) }], isError: true };
        }
        return { content: [{ type: 'text', text: JSON.stringify({ deleted: filename }) }] };
    });
}
