/**
 * Lightweight task router for natural-language requests.
 *
 * v1 scope:
 *   - Detect obvious browser/web-account tasks from plain English and route them
 *     to the browser agent (`/browse`) automatically.
 *   - Leave everything else in the normal assistant/chat flow.
 *
 * This is intentionally heuristic and transparent. We do NOT use an LLM here.
 * The goal is to hide low-level slash commands for common web tasks while being
 * conservative enough not to hijack ordinary coding questions.
 */
const WEB_SERVICE_HINTS = [
    "facebook",
    "facebook marketplace",
    "marketplace",
    "instagram",
    "x.com",
    "twitter",
    "github",
    "gmail",
    "mail",
    "linkedin",
    "reddit",
    "youtube",
    "netflix",
    "amazon",
    "stripe",
    "vercel",
    "openai",
    "claude",
    "messenger",
    "whatsapp web",
    "discord",
    "slack",
    "bank",
    "paypal",
];
const WEB_ACTION_HINTS = [
    "check if",
    "check whether",
    "see if",
    "open",
    "go to",
    "log in",
    "login",
    "sign in",
    "look at",
    "look up",
    "search",
    "find",
    "see whether",
    "did someone reply",
    "did anyone reply",
    "replied",
    "notifications",
    "messages",
    "inbox",
    "dm",
    "dms",
    "reply",
    "responded",
    "star",
    "follow",
    "unfollow",
    "delete",
    "archive",
    "buy",
    "sell",
    "listing",
    "dashboard",
    "revenue",
];
const CODING_HINTS = [
    "code",
    "repo",
    "repository",
    "function",
    "typescript",
    "javascript",
    "python",
    "swift",
    "bug",
    "compile",
    "build",
    "test",
    "refactor",
    "file",
    "directory",
    "package.json",
    "tsconfig",
    "pull request",
    "pr",
    "branch",
];
function includesAny(haystack, needles) {
    for (const n of needles) {
        if (haystack.includes(n))
            return n;
    }
    return null;
}
/**
 * Decide whether a plain-English request should be auto-routed to the browser.
 *
 * Heuristic:
 *   - Must contain at least one web action hint AND one web service hint
 *   - Must NOT look like a coding request
 */
export function routeTask(text) {
    const raw = text.trim();
    const lc = raw.toLowerCase();
    if (!raw)
        return { kind: "default", reason: "empty input" };
    const codingHit = includesAny(lc, CODING_HINTS);
    const serviceHit = includesAny(lc, WEB_SERVICE_HINTS);
    const actionHit = includesAny(lc, WEB_ACTION_HINTS);
    if (!codingHit && serviceHit && actionHit) {
        return {
            kind: "browser",
            task: raw,
            reason: `matched browser intent via service "${serviceHit}" and action "${actionHit}"`,
        };
    }
    // Also route obvious URL requests, e.g. "open https://... and ..."
    if (!codingHit && /(https?:\/\/|www\.)/i.test(raw) && actionHit) {
        return {
            kind: "browser",
            task: raw,
            reason: "matched browser intent via URL + web action",
        };
    }
    return { kind: "default", reason: codingHit ? `looks like coding task (${codingHit})` : "no browser signal" };
}
//# sourceMappingURL=task-router.js.map