"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.register = register;
const zod_1 = require("zod");
const defaults_1 = require("../../../lib/defaults");
function register(server, mgr) {
    server.registerTool('notes_list', {
        description: 'List notes in the knowledge graph. ' +
            'Optionally filter by title/id substring and/or tag. ' +
            'Returns an array of { id, title, tags, updatedAt } sorted by most recently updated.',
        inputSchema: {
            filter: zod_1.z.string().max(500).optional().describe('Case-insensitive substring to match against note title or ID'),
            tag: zod_1.z.string().max(defaults_1.MAX_TAG_LEN).optional().describe('Filter by tag (exact match, case-insensitive)'),
            limit: zod_1.z.number().int().min(1).max(1000).optional().describe('Maximum number of results'),
            offset: zod_1.z.number().int().min(0).max(100_000).optional().describe('Offset for pagination (default 0)'),
        },
    }, async ({ filter, tag, limit, offset }) => {
        const { results: notes, total } = mgr.listNotes(filter, tag, limit, offset);
        const output = notes.map(({ content: _, ...n }) => n);
        return { content: [{ type: 'text', text: JSON.stringify({ results: output, total }, null, 2) }] };
    });
}
