"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('tasks_create', {
        description: 'Create a new task in the task graph. ' +
            'The task is automatically embedded for semantic search. ' +
            'Returns the generated taskId (slug from title). ' +
            'Use link_task to connect tasks, or create_task_link to link to docs/code/files/knowledge.',
        inputSchema: {
            title: zod_1.z.string().min(1).max(defaults_1.MAX_TITLE_LEN).describe('Short title, e.g. "Fix auth redirect loop". Used to generate the task ID slug.'),
            description: zod_1.z.string().max(defaults_1.MAX_DESCRIPTION_LEN).describe('Full task description in markdown'),
            priority: zod_1.z.enum(['critical', 'high', 'medium', 'low']).describe('Priority: "critical", "high", "medium", or "low"'),
            status: zod_1.z.enum(['backlog', 'todo', 'in_progress', 'review', 'done', 'cancelled']).optional()
                .describe('Initial status: "backlog" (default), "todo", "in_progress", "review", "done", or "cancelled"'),
            tags: zod_1.z.array(zod_1.z.string().max(defaults_1.MAX_TAG_LEN)).max(defaults_1.MAX_TAGS_COUNT).optional().describe('Tags array, e.g. ["bug", "auth"]'),
            dueDate: zod_1.z.number().optional().describe('Due date as Unix timestamp in milliseconds, e.g. 1735689600000'),
            estimate: zod_1.z.number().optional().describe('Estimated effort in hours, e.g. 4'),
            assignee: zod_1.z.string().max(defaults_1.MAX_ASSIGNEE_LEN).optional().describe('Team member ID to assign the task to'),
            order: zod_1.z.number().int().optional().describe('Position within status group (integer, lower = higher). Auto-assigned if omitted.'),
        },
    }, async ({ title, description, priority, status, tags, dueDate, estimate, assignee, order }) => {
        const taskId = await mgr.createTask(title, description, status ?? 'backlog', priority, tags ?? [], dueDate ?? null, estimate ?? null, assignee ?? null, order);
        return { content: [{ type: 'text', text: JSON.stringify({ taskId }, null, 2) }] };
    });
}
