import { getSeedToolSurface } from "./tool-surface.js";
const READ_ONLY_TOOLS = new Set([
    "cat",
    "find",
    "glob",
    "grep",
    "head",
    "list",
    "ls",
    "read",
    "rg",
    "search",
    "sed",
    "tail",
    "view",
    "wc",
    "webfetch",
    "websearch",
]);
const WRITE_FILE_TOOLS = new Set([
    "apply_patch",
    "edit",
    "multi_edit",
    "notebook_edit",
    "patch",
    "str_replace",
    "write",
]);
const SHELL_TOOLS = new Set(["bash", "run", "shell", "sh", "terminal"]);
export function classifyToolName(toolName) {
    const normalized = normalizeToolName(toolName);
    const surface = getSeedToolSurface(normalized);
    const kind = classifyNormalizedToolName(normalized);
    return {
        tool_name: toolName,
        normalized_tool_name: normalized,
        kind,
        reason: surface?.reason ?? classificationReason(normalized, kind),
    };
}
export function normalizeToolName(toolName) {
    return toolName.trim().toLowerCase();
}
function classifyNormalizedToolName(toolName) {
    if (!toolName)
        return "unknown";
    if (toolName.startsWith("mcp__"))
        return "mcp_or_external";
    const seedSurface = getSeedToolSurface(toolName);
    if (seedSurface)
        return seedSurface.kind;
    if (toolName.startsWith("seed_"))
        return "unknown";
    if (READ_ONLY_TOOLS.has(toolName))
        return "read_only";
    if (WRITE_FILE_TOOLS.has(toolName))
        return "write_file";
    if (SHELL_TOOLS.has(toolName))
        return "shell";
    return "unknown";
}
function classificationReason(toolName, kind) {
    switch (kind) {
        case "read_only":
            return "Tool name is a known read-only surface.";
        case "write_file":
            return "Tool name is a known direct file-write surface.";
        case "shell":
            return "Tool name executes a shell command and must be inspected through its command args.";
        case "seed_workspace":
            return "Tool is a SEED workspace coordination surface with structured path args.";
        case "seed_coordination":
            return "Tool is a SEED coordination surface.";
        case "seed_delegation":
            return "Tool is a SEED delegation/orchestration surface.";
        case "seed_command_exec":
            return "Tool is a SEED stateful command execution surface reserved for Lab-Representative.";
        case "seed_evidence_capture":
            return "Tool is a SEED evidence capture surface.";
        case "mcp_or_external":
            return "Tool is provided by MCP or another external namespace.";
        case "unknown":
            return toolName ? "Tool name is not recognized by the SEED hook classifier." : "Tool name is empty.";
    }
}
//# sourceMappingURL=tool-classifier.js.map