/**
 * Phase 1 — CliRuntime
 * Central execution router. Receives a CommandEnvelope and delegates to the
 * appropriate controller based on envelope.kind.
 */
import { handleRunCommand } from "./run-controller.js";
import { handleTaskCommand } from "./task-controller.js";
import { handlePlanCommand } from "./plan-controller.js";
export function createCliRuntime() {
    return {
        async execute(envelope) {
            switch (envelope.kind) {
                case "run":
                    return handleRunCommand(envelope);
                case "task":
                    return handleTaskCommand(envelope);
                case "plan":
                    return handlePlanCommand(envelope);
                default: {
                    return {
                        command: envelope.kind,
                        success: false,
                        exitCode: 2,
                        events: [],
                        error: {
                            kind: "usage",
                            message: `Command "${envelope.kind}" is not yet implemented in the runtime bridge.`,
                            hint: "Supported commands: run, task, plan",
                        },
                    };
                }
            }
        },
    };
}
