// tools/orchestrate-agents-handler.ts — Handler stub (agent-orchestrator removed in SPEC-533)
import { getSpec } from '../storage/spec-store.js';
import { resolveProjectId } from './resolve-project-id.js';
const DEFAULT_AGENT_COUNT = 3;
export async function handleOrchestrateAgents(args) {
    const projectId = resolveProjectId({ projectPath: args.projectPath });
    if (!projectId) {
        return {
            content: [{ type: 'text', text: 'Error: Could not derive project ID from projectPath.' }],
            isError: true,
        };
    }
    const spec = await getSpec(projectId, args.specId);
    if (!spec) {
        return {
            content: [
                {
                    type: 'text',
                    text: `Error: Spec "${args.specId}" not found in project at ${args.projectPath}.`,
                },
            ],
            isError: true,
        };
    }
    const agentCount = args.agentCount ?? DEFAULT_AGENT_COUNT;
    // Generate a basic orchestration plan
    const agents = [];
    for (let i = 0; i < agentCount; i++) {
        agents.push([
            `## Specialist ${String(i + 1)} [Wave ${i === 0 ? '1' : '2 (parallel)'}]`,
            '',
            `**Spec:** ${args.specId} — ${spec.title}`,
            `**Scope:** ${spec.scope} | **Type:** ${spec.type}`,
            `**Tags:** ${spec.tags.join(', ') || 'none'}`,
            '',
            '---',
        ].join('\n'));
    }
    const output = [
        `# Multi-Agent Orchestration Plan`,
        `**Spec:** ${args.specId} — ${spec.title}`,
        `**Agents:** ${String(agentCount)} specialists`,
        '',
        ...agents,
    ].join('\n');
    return {
        content: [{ type: 'text', text: output }],
        isError: false,
    };
}
/**
 * SPEC-694: Build a compact orchestration plan summary for the update_status(approved) cascade.
 * Returns null on any error so the cascade continues silently.
 */
export async function buildOrchestrationPlanSummary(specId, projectPath) {
    const projectId = resolveProjectId({ projectPath });
    if (!projectId) {
        return null;
    }
    const spec = await getSpec(projectId, specId);
    if (!spec) {
        return null;
    }
    const names = Array.from({ length: DEFAULT_AGENT_COUNT }, (_, i) => `Specialist-${String(i + 1)}`);
    const executionOrder = ['Wave 1: Coordinator', `Wave 2: ${names.join(', ')}`, 'Wave 3: Verifier'];
    const fileOwnership = Object.fromEntries(names.map((n) => [n, []]));
    const flat = Object.values(fileOwnership).flat();
    return {
        executionOrder,
        fileOwnership,
        parallelSafetyVerdict: flat.length === new Set(flat).size,
    };
}
//# sourceMappingURL=orchestrate-agents-handler.js.map