import { gotoTool } from "./goto.js";
import { actTool } from "./act.js";
import { screenshotTool } from "./screenshot.js";
import { waitTool } from "./wait.js";
import { navBackTool } from "./navback.js";
import { ariaTreeTool } from "./ariaTree.js";
import { fillFormTool } from "./fillform.js";
import { scrollTool, scrollVisionTool } from "./scroll.js";
import { extractTool } from "./extract.js";
import { clickTool } from "./click.js";
import { typeTool } from "./type.js";
import { dragAndDropTool } from "./dragAndDrop.js";
import { clickAndHoldTool } from "./clickAndHold.js";
import { keysTool } from "./keys.js";
import { fillFormVisionTool } from "./fillFormVision.js";
import { thinkTool } from "./think.js";
import { searchTool } from "./search.js";
/**
 * Filters tools based on mode and explicit exclusions.
 * - 'dom' mode: Removes coordinate-based tools (click, type, dragAndDrop, clickAndHold, fillFormVision)
 * - 'hybrid' mode: Removes DOM-based form tool (fillForm) in favor of coordinate-based fillFormVision
 * - excludeTools: Additional tools to remove from the toolset
 */
function filterTools(tools, mode, excludeTools) {
    const filtered = { ...tools };
    // Mode-based filtering
    if (mode === "hybrid") {
        delete filtered.fillForm;
    }
    else {
        // DOM mode (default)
        delete filtered.click;
        delete filtered.type;
        delete filtered.dragAndDrop;
        delete filtered.clickAndHold;
        delete filtered.fillFormVision;
    }
    if (excludeTools) {
        for (const toolName of excludeTools) {
            delete filtered[toolName];
        }
    }
    return filtered;
}
export function createAgentTools(v3, options) {
    const executionModel = options?.executionModel;
    const mode = options?.mode ?? "dom";
    const provider = options?.provider;
    const excludeTools = options?.excludeTools;
    const variables = options?.variables;
    const allTools = {
        act: actTool(v3, executionModel, variables),
        ariaTree: ariaTreeTool(v3),
        click: clickTool(v3, provider),
        clickAndHold: clickAndHoldTool(v3, provider),
        dragAndDrop: dragAndDropTool(v3, provider),
        extract: extractTool(v3, executionModel),
        fillForm: fillFormTool(v3, executionModel, variables),
        fillFormVision: fillFormVisionTool(v3, provider, variables),
        goto: gotoTool(v3),
        keys: keysTool(v3),
        navback: navBackTool(v3),
        screenshot: screenshotTool(v3),
        scroll: mode === "hybrid" ? scrollVisionTool(v3, provider) : scrollTool(v3),
        think: thinkTool(),
        type: typeTool(v3, provider, variables),
        wait: waitTool(v3, mode),
    };
    // Only include search tool if BRAVE_API_KEY is configured
    if (process.env.BRAVE_API_KEY) {
        allTools.search = searchTool(v3);
    }
    return filterTools(allTools, mode, excludeTools);
}
//# sourceMappingURL=index.js.map