// Planu — Agent Spec Generator: Execution Phases
// SPEC-016a: Generates agent-specific execution plan phases.
function ext(lang) {
    return lang === 'python' ? 'py' : 'ts';
}
function buildCorePhaseSteps(slug, e, order) {
    return [
        {
            order,
            title: 'Implement agent core loop',
            description: `Set up LLM client, system prompt, and basic agent loop`,
            files: [`src/agents/${slug}/core.${e}`, `src/agents/${slug}/prompts.${e}`],
            dependsOn: [],
            verification: 'Agent initializes without errors; basic prompt-response cycle works',
            estimatedMinutes: 120,
            canRollback: true,
        },
        {
            order: order + 1,
            title: 'Define agent constitution and safety guardrails',
            description: 'Implement accuracy, safety, privacy, and escalation rules',
            files: [`src/agents/${slug}/constitution.${e}`],
            dependsOn: [order],
            verification: 'Constitution enforced: harmful inputs rejected, PII masked',
            estimatedMinutes: 60,
            canRollback: true,
        },
    ];
}
function buildToolsPhaseSteps(slug, e, order) {
    return [
        {
            order,
            title: 'Implement tool definitions and handlers',
            description: 'Define tool schemas and implement each tool with input validation',
            files: [`src/agents/${slug}/tools/index.${e}`, `src/agents/${slug}/tools/validate.${e}`],
            dependsOn: [order - 1],
            verification: 'Each tool callable independently; invalid inputs return typed errors',
            estimatedMinutes: 180,
            canRollback: true,
        },
        {
            order: order + 1,
            title: 'Integrate tools into agent loop',
            description: 'Wire tool calls into agent: parse LLM tool requests, execute, return results',
            files: [`src/agents/${slug}/tool-executor.${e}`],
            dependsOn: [order],
            verification: 'Agent can call each tool; results correctly fed back into context',
            estimatedMinutes: 90,
            canRollback: true,
        },
    ];
}
function buildLaterPhaseSteps(slug, e, order) {
    return [
        {
            order,
            title: 'Set up knowledge ingestion pipeline',
            description: 'Implement document ingestion, chunking, embedding, and vector store upsert',
            files: [
                `src/agents/${slug}/knowledge/ingest.${e}`,
                `src/agents/${slug}/knowledge/retrieval.${e}`,
            ],
            dependsOn: [order - 1],
            verification: 'Documents ingested and retrievable; similarity search returns relevant chunks',
            estimatedMinutes: 150,
            canRollback: true,
        },
        {
            order: order + 1,
            title: 'Write agent test suite',
            description: 'Happy path, tool failure, iteration limit, prompt injection, determinism tests',
            files: [
                `tests/agents/${slug}/happy-path.test.${e}`,
                `tests/agents/${slug}/adversarial.test.${e}`,
            ],
            dependsOn: [order - 2],
            verification: 'All tests pass; coverage >= 80%; adversarial suite: 0 failures',
            estimatedMinutes: 120,
            canRollback: false,
        },
        {
            order: order + 2,
            title: 'Containerize and configure deployment',
            description: 'Dockerfile, environment config, health check endpoint',
            files: ['Dockerfile', 'docker-compose.yml', '.env.example'],
            dependsOn: [order],
            verification: 'Container starts; health check returns 200; env vars documented',
            estimatedMinutes: 60,
            canRollback: true,
        },
        {
            order: order + 3,
            title: 'Set up LLM observability and cost tracking',
            description: 'Configure tracing (LangSmith/OpenTelemetry), cost dashboards, safety monitors',
            files: [
                `src/agents/${slug}/monitoring/tracing.${e}`,
                `src/agents/${slug}/monitoring/cost-guard.${e}`,
            ],
            dependsOn: [order + 1],
            verification: 'Traces visible in observability platform; cost alerts configured',
            estimatedMinutes: 90,
            canRollback: true,
        },
    ];
}
/**
 * Generate agent-specific execution phases.
 * Criteria 5: agent_core, tools_integration, knowledge_ingestion, testing, deployment, monitoring.
 */
export function generateAgentExecutionPhases(spec, knowledge, startOrder) {
    const e = ext(knowledge.language);
    const { slug } = spec;
    const core = buildCorePhaseSteps(slug, e, startOrder);
    const tools = buildToolsPhaseSteps(slug, e, startOrder + 2);
    const later = buildLaterPhaseSteps(slug, e, startOrder + 4);
    return [...core, ...tools, ...later];
}
//# sourceMappingURL=execution-phases.js.map