"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.register = register;
const zod_1 = require("zod");
function register(server, mgr) {
    server.registerTool('tasks_remove_attachment', {
        description: 'Remove an attachment from a task. The file is deleted from disk.',
        inputSchema: {
            taskId: zod_1.z.string().min(1).max(500).describe('Task ID (slug)'),
            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 ({ taskId, filename }) => {
        const ok = mgr.removeAttachment(taskId, 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 }) }] };
    });
}
