const COMMAND_ALIASES = {
    ask: "question",
    q: "question",
    question: "question",
    help: "help",
    h: "help",
    variants: "variants",
    variant: "variants",
    v: "variants",
    n: "variants",
    generate: "generate",
    gen: "generate",
    g: "generate",
    parallel: "parallelism",
    parallelism: "parallelism",
    p: "parallelism",
};
export function parseAgentSlashCommand(input) {
    const raw = input.trim();
    if (!raw.startsWith("/"))
        return null;
    const match = /^\/([a-z][\w-]*)(?:\s+([\s\S]*))?$/i.exec(raw);
    if (!match)
        return null;
    const rawName = match[1].toLowerCase();
    const name = COMMAND_ALIASES[rawName];
    if (!name)
        return null;
    const rest = (match[2] ?? "").trim();
    const countCommands = ["variants", "generate", "parallelism"];
    const parsed = countCommands.includes(name) ? parseLeadingCount(rest) : { prompt: rest };
    return {
        name,
        rawName,
        raw,
        prompt: parsed.prompt,
        ...(parsed.value ? { value: parsed.value } : {}),
    };
}
export function formatAgentSlashHelp() {
    return [
        "Available Agent commands:",
        "/question <topic> - ask a planning question without generating images.",
        "/variants <1-8> <prompt> - force that many image variants.",
        "/generate <1-8> <prompt> - generate a bounded fanout from one request.",
        "/parallelism <1-8> <prompt> - cap concurrent tool calls for this turn.",
    ].join("\n");
}
export function formatAgentQuestionReply(prompt) {
    const topic = prompt.trim();
    if (!topic) {
        return "What would you like to clarify before generating images?";
    }
    return topic;
}
function parseLeadingCount(value) {
    const match = /^(\d+)(?:\s+([\s\S]*))?$/.exec(value);
    if (!match)
        return { prompt: value };
    return {
        value: Math.max(1, Math.min(8, Number(match[1]))),
        prompt: (match[2] ?? "").trim(),
    };
}
