/**
 * VIBE Orchestrator - Agent SDK 기반 멀티 에이전트 오케스트레이션
 *
 * 사용법 (hooks에서):
 *   node -e "import('@su-record/vibe/orchestrator').then(o => o.parallelResearch({...})).then(console.log)"
 *
 * 사용법 (코드에서):
 *   import { CoreOrchestrator, parallelResearch } from '@su-record/vibe/orchestrator';
 */
// Smart Routing constants
export { TASK_LLM_PRIORITY } from './types.js';
// Agent Discovery
export { discoverAgents, loadAgent, listAgentsByCategory, parseAgentMarkdown, extractCategory } from './agentDiscovery.js';
// Agent Manifest Cache
export { AgentManifestCache } from './AgentManifestCache.js';
// Parallel Research
export { parallelResearch, researchFeature, createResearchTasks, 
// Multi-LLM Research
parallelResearchWithMultiLlm, executeMultiLlmResearch, formatMultiLlmResults } from './parallelResearch.js';
// Background Agent
export { launchBackgroundAgent, getBackgroundAgentResult, cancelBackgroundAgent, listActiveSessions, getSessionHistory, launchParallelAgents, 
// BackgroundManager
backgroundManager, launch, poll, cancel, getStats, QueueOverflowError, TaskTimeoutError, PipelineTimeoutError, AgentExecutionError } from './backgroundAgent.js';
// Main Orchestrator Class
export { CoreOrchestrator, getOrchestrator } from './orchestrator.js';
// Decomposed Components
export { SmartRouter, getSmartRouter, AllProvidersFailedError } from './SmartRouter.js';
export { LLMCluster, getLLMCluster } from './LLMCluster.js';
export { AgentManager, getAgentManager } from './AgentManager.js';
// AgentAnnouncer
export { AgentAnnouncer, agentAnnouncer } from './AgentAnnouncer.js';
// AgentRegistry
export { AgentRegistry } from './AgentRegistry.js';
// PhasePipeline
export { PhasePipeline, createStage, createPipeline, createUltraworkPipeline, pipelineResultToToolResult } from './PhasePipeline.js';
// PhaseResultStore
export { PhaseResultStore } from './PhaseResultStore.js';
// CheckpointManager
export { CheckpointManager } from './CheckpointManager.js';
// SwarmOrchestrator
export { SwarmOrchestrator, swarm, analyzeTaskComplexity } from './SwarmOrchestrator.js';
// ============================================
// 간편 함수 (hooks에서 직접 호출용)
// ============================================
import { CoreOrchestrator } from './orchestrator.js';
import { parallelResearchWithMultiLlm as _parallelResearchWithMultiLlm, createResearchTasks } from './parallelResearch.js';
import { launchBackgroundAgent as _launchBackgroundAgent, getBackgroundAgentResult as _getBackgroundAgentResult, listActiveSessions, getSessionHistory } from './backgroundAgent.js';
import { discoverAgents as _discoverAgents } from './agentDiscovery.js';
/**
 * 기능 기반 병렬 리서치 (간편 API)
 *
 * @example
 * node -e "import('@su-record/vibe/orchestrator').then(o => o.research('login feature', ['React', 'TypeScript'])).then(console.log)"
 */
export async function research(feature, techStack = [], projectPath = process.cwd()) {
    const tasks = createResearchTasks(feature, techStack);
    // Multi-LLM 리서치 (Claude 에이전트 + GPT + Antigravity 병렬 실행)
    return _parallelResearchWithMultiLlm({ tasks, projectPath, feature, techStack });
}
/**
 * 백그라운드 에이전트 시작 (간편 API)
 *
 * @example
 * node -e "import('@su-record/vibe/orchestrator').then(o => o.runAgent('Fix the login bug', 'bug-fixer')).then(console.log)"
 */
export async function runAgent(prompt, agentName, projectPath = process.cwd()) {
    return _launchBackgroundAgent({
        prompt,
        agentName: agentName || `agent-${Date.now()}`,
        projectPath
    });
}
/**
 * 에이전트 결과 조회 (간편 API)
 *
 * @example
 * node -e "import('@su-record/vibe/orchestrator').then(o => o.getResult('session-id')).then(console.log)"
 */
export async function getResult(sessionId) {
    return _getBackgroundAgentResult(sessionId);
}
/**
 * 에이전트 목록 조회 (간편 API)
 *
 * @example
 * node -e "import('@su-record/vibe/orchestrator').then(o => o.listAgents()).then(console.log)"
 */
export async function listAgents(category, projectPath = process.cwd()) {
    return _discoverAgents({ projectPath, category });
}
/**
 * 병렬 리뷰 실행 (간편 API)
 *
 * @example
 * node -e "import('@su-record/vibe/orchestrator').then(o => o.review(['src/api/user.ts'], ['TypeScript'])).then(console.log)"
 */
export async function review(filePaths, techStack = [], projectPath = process.cwd()) {
    const orchestrator = new CoreOrchestrator({ projectPath });
    const results = await orchestrator.runParallelReview(filePaths, techStack);
    // 결과 포맷팅
    let summary = `## Parallel Review Results\n\n`;
    summary += `**Files**: ${filePaths.length}\n`;
    summary += `**Reviewers**: ${results.length}\n\n`;
    const successCount = results.filter(r => r.success).length;
    summary += `**Success**: ${successCount}/${results.length}\n\n`;
    for (const result of results) {
        const status = result.success ? '✅' : '❌';
        summary += `### ${status} ${result.agentName}\n`;
        if (result.success) {
            summary += result.result.slice(0, 500);
            if (result.result.length > 500)
                summary += '...';
        }
        else {
            summary += `Error: ${result.error}`;
        }
        summary += '\n\n';
    }
    return {
        content: [{ type: 'text', text: summary }],
        results
    };
}
/**
 * 오케스트레이터 상태 확인
 *
 * @example
 * node -e "import('@su-record/vibe/orchestrator').then(o => o.status()).then(console.log)"
 */
export function status() {
    const active = listActiveSessions();
    const history = getSessionHistory(5);
    return {
        content: [{
                type: 'text',
                text: `## Orchestrator Status\n\n${active.content[0].text}\n\n${history.content[0].text}`
            }]
    };
}
// ============================================
// LLM Integration (GPT, Antigravity)
// ============================================
import * as gptApi from '../lib/gpt/index.js';
import * as antigravityApi from '../lib/antigravity/index.js';
// ============================================
// GPT Integration (웹 검색, 아키텍처 분석)
// ============================================
/**
 * GPT 질문 (간편 API) - 웹 검색 없음, Antigravity로 위임
 *
 * @example
 * node -e "import('@su-record/vibe/orchestrator').then(o => o.gptSearch('React 19 features')).then(console.log)"
 * @deprecated GPT Codex API는 웹 검색을 지원하지 않습니다. antigravitySearch를 사용하세요.
 */
export async function gptSearch(query) {
    // GPT Codex API는 웹 검색 미지원 → Antigravity로 위임
    return antigravitySearch(query);
}
/**
 * GPT 오케스트레이션 (간편 API)
 *
 * @example
 * node -e "import('@su-record/vibe/orchestrator').then(o => o.gpt('Analyze this architecture')).then(console.log)"
 */
export async function gpt(prompt, systemPrompt = 'You are a helpful assistant.') {
    try {
        const result = await gptApi.coreGptOrchestrate(prompt, systemPrompt, { jsonMode: false });
        return {
            content: [{ type: 'text', text: result }],
            success: true
        };
    }
    catch (error) {
        return {
            content: [{ type: 'text', text: `[GPT Error] ${error.message}` }],
            success: false
        };
    }
}
// ============================================
// Antigravity Integration (UI/UX 분석, 코드 분석)
// ============================================
/**
 * Antigravity 웹 검색 (간편 API)
 *
 * @example
 * node -e "import('@su-record/vibe/orchestrator').then(o => o.antigravitySearch('React 19 features')).then(console.log)"
 */
export async function antigravitySearch(query) {
    try {
        const result = await antigravityApi.quickWebSearch(query);
        return {
            content: [{ type: 'text', text: result }],
            success: true
        };
    }
    catch (error) {
        return {
            content: [{ type: 'text', text: `[Antigravity Error] ${error.message}` }],
            success: false
        };
    }
}
/**
 * Antigravity 오케스트레이션 (간편 API)
 *
 * @example
 * node -e "import('@su-record/vibe/orchestrator').then(o => o.antigravity('Review this UI')).then(console.log)"
 */
export async function antigravity(prompt, systemPrompt = 'You are a helpful assistant.') {
    try {
        const result = await antigravityApi.coreAntigravityOrchestrate(prompt, systemPrompt, { jsonMode: false });
        return {
            content: [{ type: 'text', text: result }],
            success: true
        };
    }
    catch (error) {
        return {
            content: [{ type: 'text', text: `[Antigravity Error] ${error.message}` }],
            success: false
        };
    }
}
// ============================================
// Multi-LLM Orchestration
// ============================================
/**
 * 멀티 LLM 병렬 쿼리 (간편 API)
 * GPT, Antigravity 동시 호출
 *
 * @example
 * node -e "import('@su-record/vibe/orchestrator').then(o => o.multiLlm('Review this code')).then(console.log)"
 */
export async function multiLlm(prompt, options) {
    const orchestrator = new CoreOrchestrator();
    const results = await orchestrator.multiLlmQuery(prompt, options);
    let summary = '## Multi-LLM Results\n\n';
    if (results.gpt) {
        summary += `### GPT\n${results.gpt}\n\n`;
    }
    if (results.antigravity) {
        summary += `### Antigravity\n${results.antigravity}\n\n`;
    }
    return {
        content: [{ type: 'text', text: summary }],
        results
    };
}
/**
 * LLM 상태 확인 (간편 API)
 *
 * @example
 * node -e "import('@su-record/vibe/orchestrator').then(o => o.llmStatus()).then(console.log)"
 */
export async function llmStatus() {
    const orchestrator = new CoreOrchestrator();
    const llmStatusResult = await orchestrator.checkLlmStatus();
    const gptIcon = llmStatusResult.gpt.available ? '✓' : '✗';
    const antigravityIcon = llmStatusResult.antigravity.available ? '✓' : '✗';
    let text = '## LLM Status\n\n';
    text += `- GPT: ${gptIcon} ${llmStatusResult.gpt.available ? 'Available' : 'Unavailable'}\n`;
    text += `- Antigravity: ${antigravityIcon} ${llmStatusResult.antigravity.available ? 'Available' : 'Unavailable'}\n`;
    return {
        content: [{ type: 'text', text }],
        status: llmStatusResult
    };
}
/**
 * 스마트 라우팅 - 작업 유형에 따라 최적의 LLM 선택 + 자동 fallback
 *
 * @example
 * node -e "import('@su-record/vibe/orchestrator').then(o => o.smartRoute({type:'architecture',prompt:'Review this design'})).then(console.log)"
 */
export async function smartRoute(type, prompt, systemPrompt) {
    const orchestrator = new CoreOrchestrator();
    const result = await orchestrator.smartRoute({ type, prompt, systemPrompt });
    const fallbackInfo = result.usedFallback
        ? ` (fallback from ${result.attemptedProviders.slice(0, -1).join(' → ')})`
        : '';
    return {
        content: [{
                type: 'text',
                text: `[${result.provider.toUpperCase()}${fallbackInfo}]\n\n${result.content}`
            }],
        result
    };
}
/**
 * 아키텍처 분석 with fallback (GPT → Antigravity → Claude)
 *
 * @example
 * node -e "import('@su-record/vibe/orchestrator').then(o => o.smartArchitecture('Review this system design')).then(console.log)"
 */
export async function smartArchitecture(prompt) {
    return smartRoute('architecture', prompt, 'You are a software architect. Analyze and review the architecture.');
}
/**
 * UI/UX 분석 with fallback (Antigravity → GPT → Claude)
 *
 * @example
 * node -e "import('@su-record/vibe/orchestrator').then(o => o.smartUiux('Improve this form UX')).then(console.log)"
 */
export async function smartUiux(prompt) {
    return smartRoute('uiux', prompt, 'You are a UI/UX expert. Analyze and provide feedback.');
}
/**
 * 코드 분석 with fallback (Antigravity → GPT → Claude)
 *
 * @example
 * node -e "import('@su-record/vibe/orchestrator').then(o => o.smartCodeAnalysis('Analyze this code')).then(console.log)"
 */
export async function smartCodeAnalysis(prompt) {
    return smartRoute('code-analysis', prompt, 'You are a code analysis expert. Review and analyze the code.');
}
/**
 * 디버깅 with fallback (GPT → Antigravity → Claude)
 *
 * @example
 * node -e "import('@su-record/vibe/orchestrator').then(o => o.smartDebugging('Find bugs in this code')).then(console.log)"
 */
export async function smartDebugging(prompt) {
    return smartRoute('debugging', prompt, 'You are a debugging expert. Find bugs and suggest fixes.');
}
/**
 * 웹 검색 with fallback (GPT → Antigravity → Claude)
 *
 * @example
 * node -e "import('@su-record/vibe/orchestrator').then(o => o.smartWebSearch('React 19 new features')).then(console.log)"
 */
export async function smartWebSearch(query) {
    return smartRoute('web-search', query, 'Search the web and provide relevant information.');
}
/**
 * 코드 생성 with fallback (Claude 직접)
 *
 * @example
 * node -e "import('@su-record/vibe/orchestrator').then(o => o.smartCodeGen('Create a React button component')).then(console.log)"
 */
export async function smartCodeGen(description, context) {
    const prompt = context ? `${description}\n\nContext:\n${context}` : description;
    return smartRoute('code-gen', prompt, 'Generate clean, well-documented code.');
}
/**
 * 코드 리뷰 with fallback (GPT → Antigravity → Claude)
 *
 * @example
 * node -e "import('@su-record/vibe/orchestrator').then(o => o.smartCodeReview('Review this PR')).then(console.log)"
 */
export async function smartCodeReview(prompt) {
    return smartRoute('code-review', prompt, 'You are a code review expert. Review the code for bugs, style, and best practices.');
}
/**
 * 추론/분석 with fallback (GPT → Antigravity → Claude)
 *
 * @example
 * node -e "import('@su-record/vibe/orchestrator').then(o => o.smartReasoning('Analyze this problem')).then(console.log)"
 */
export async function smartReasoning(prompt) {
    return smartRoute('reasoning', prompt, 'You are a reasoning expert. Analyze the problem step by step.');
}
//# sourceMappingURL=index.js.map