/**
 * Plan-and-Execute pattern — decompose a task in `decide`, execute step by step in `act`.
 *
 * decomposeTask() converts an orient output into a sequence of ordered steps.
 * executeStep() runs one step with tool access, producing a step result.
 *
 * @public
 */
// ─── Decompose ──────────────────────────────────────────────────────────────────
/**
 * Convert a task description into a structured plan.
 *
 * The `decomposer` function is an LLM call that takes a task description
 * and returns a Plan with ordered steps. Implementations should use
 * structured output (Zod schema) for reliable parsing.
 */
export async function decomposeTask(task, decomposer) {
    return decomposer(task);
}
// ─── Execute ────────────────────────────────────────────────────────────────────
/**
 * Execute a single plan step.
 *
 * Returns a StepResult with status, output, and timing.
 */
export async function executeStep(step, executor) {
    const start = Date.now();
    try {
        const output = await executor(step);
        return { stepIndex: step.index, status: "completed", output, durationMs: Date.now() - start };
    }
    catch (err) {
        return {
            stepIndex: step.index,
            status: "failed",
            error: err instanceof Error ? err.message : String(err),
            durationMs: Date.now() - start,
        };
    }
}
//# sourceMappingURL=plan-execute.js.map