import { z } from 'zod';
import { handleOrchestrateAgents } from './orchestrate-agents.js';
import { safeLicensed } from './safe-handler.js';
export function registerAgentTools(server) {
    server.registerTool('orchestrate_agents', {
        description: 'Declare agent capabilities, route tasks to the best agent, generate structured handoff contexts, and detect file-ownership conflicts before parallel execution. Supports register-agent | list-agents | route-task | decompose-spec | handoff | conflict-check.',
        inputSchema: {
            action: z
                .enum([
                'register-agent',
                'list-agents',
                'route-task',
                'decompose-spec',
                'handoff',
                'conflict-check',
            ])
                .describe('Action: register-agent (declare capability) | list-agents (list registered) | route-task (assign best agent) | decompose-spec (triad distribution) | handoff (structured context) | conflict-check (file overlap detection)'),
            projectId: z
                .string()
                .max(500)
                .optional()
                .describe('Project ID for persistence — defaults to "global"'),
            agentId: z
                .string()
                .max(500)
                .optional()
                .describe('register-agent: unique identifier for the agent'),
            role: z
                .enum(['planner', 'implementer', 'reviewer', 'tester', 'researcher'])
                .optional()
                .describe('register-agent: primary role the agent fulfils'),
            ecosystems: z
                .array(z.string().max(500))
                .max(100)
                .optional()
                .describe('register-agent: ecosystems the agent handles (e.g. ["typescript","python"])'),
            filePatterns: z
                .array(z.string().max(4096))
                .max(1000)
                .optional()
                .describe('register-agent: glob patterns for files the agent owns'),
            maxConcurrency: z
                .number()
                .int()
                .positive()
                .optional()
                .describe('register-agent: max concurrent tasks (default: 1)'),
            preferredModel: z
                .enum(['haiku', 'sonnet', 'opus'])
                .optional()
                .describe('register-agent: preferred model tier (default: sonnet)'),
            taskDescription: z
                .string()
                .max(10_000)
                .optional()
                .describe('route-task | decompose-spec: natural-language description of the task'),
            specCriteria: z
                .array(z.string().max(10_000))
                .max(1000)
                .optional()
                .describe('decompose-spec: acceptance criteria to distribute across agents'),
            availableAgents: z
                .array(z.string().max(500))
                .max(100)
                .optional()
                .describe('decompose-spec: agent IDs available for assignment'),
            sessionContext: z
                .object({
                fromAgent: z.string().max(500).describe('Agent ID handing off work'),
                toAgent: z.string().max(500).describe('Agent ID receiving work'),
                completedWork: z
                    .array(z.string().max(10_000))
                    .max(1000)
                    .describe('Short descriptions of completed work'),
                decisions: z
                    .array(z.object({
                    decision: z.string().max(10_000),
                    rationale: z.string().max(10_000),
                }))
                    .max(1000)
                    .describe('Architectural decisions made during the session'),
                fileOwnershipMap: z
                    .record(z.string().max(4096), z.string().max(500))
                    .describe('Map of file path → agentId that last modified it'),
                pendingWork: z
                    .array(z.object({ task: z.string().max(10_000), context: z.string().max(10_000) }))
                    .max(1000)
                    .describe('Unfinished tasks with context for the receiving agent'),
            })
                .optional()
                .describe('handoff: session context object'),
            agentPlans: z
                .array(z.object({
                agentId: z.string().max(500).describe('Agent ID submitting this plan'),
                ownedFiles: z
                    .array(z.string().max(4096))
                    .max(1000)
                    .describe('Files the agent intends to modify'),
            }))
                .optional()
                .describe('conflict-check: array of per-agent plans'),
        },
        annotations: { readOnlyHint: false },
    }, safeLicensed('orchestrate_agents', async (args) => handleOrchestrateAgents(args)));
}
//# sourceMappingURL=register-agent-tools.js.map