"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Planner = void 0;
class Planner {
    /**
     * Create a plan based on the user's prompt
     * This is a simplified implementation - in reality, this would use
     * the LLM to generate a proper plan
     */
    async createPlan(prompt) {
        const plan = [];
        // Simple keyword-based planning (would be replaced with LLM-based planning)
        const lowerPrompt = prompt.toLowerCase();
        if (lowerPrompt.includes("read") || lowerPrompt.includes("show") || lowerPrompt.includes("display")) {
            // Extract potential file names (very simplified)
            const words = prompt.split(/\s+/);
            for (let i = 0; i < words.length; i++) {
                if (words[i].includes(".") && !words[i].startsWith("http")) {
                    plan.push({
                        id: plan.length + 1,
                        description: `Read file: ${words[i]}`,
                        tool: "read_file",
                        toolArgs: { filePath: words[i] },
                        completed: false
                    });
                    break;
                }
            }
        }
        if (lowerPrompt.includes("write") || lowerPrompt.includes("create") || lowerPrompt.includes("save")) {
            // Extract potential file names and content
            plan.push({
                id: plan.length + 1,
                description: "Write/create file",
                tool: "write_file",
                toolArgs: { filePath: "output.txt", content: "" }, // Would be filled in by LLM
                completed: false
            });
        }
        if (lowerPrompt.includes("run") || lowerPrompt.includes("execute") || lowerPrompt.includes("command")) {
            plan.push({
                id: plan.length + 1,
                description: "Run command",
                tool: "run_command",
                toolArgs: { command: "" }, // Would be filled in by LLM
                completed: false
            });
        }
        // If no specific tools identified, assume we need to provide information
        if (plan.length === 0) {
            plan.push({
                id: 1,
                description: "Provide answer based on knowledge",
                completed: false
            });
        }
        return plan;
    }
    /**
     * Validate that a plan makes sense
     */
    validatePlan(plan) {
        // Basic validation
        return plan.length > 0 && plan.every(step => step.id > 0 && step.description.trim().length > 0);
    }
    /**
     * Get the next incomplete step in the plan
     */
    getNextStep(plan) {
        return plan.find(step => !step.completed) || null;
    }
    /**
     * Mark a step as completed
     */
    markStepCompleted(plan, stepId) {
        return plan.map(step => step.id === stepId ? { ...step, completed: true } : step);
    }
    /**
     * Check if the plan is complete
     */
    isPlanComplete(plan) {
        return plan.every(step => step.completed);
    }
}
exports.Planner = Planner;
//# sourceMappingURL=planner.js.map