import { classifyToolName } from "./tool-classifier.js";
import { analyzeShellCommand, extractCommandFromArgs, extractStructuredToolPaths, extractWorkspaceToolPaths, extractWriteToolPaths } from "./path-extractor.js";
export function assessToolHookCapability(input) {
    const tool = classifyToolName(input.toolName);
    switch (tool.kind) {
        case "read_only": {
            const paths = extractStructuredToolPaths(input.args, "read");
            return {
                schema_version: 1,
                tool,
                enforceable: true,
                file_effect: paths.length > 0 ? "read" : "none",
                paths,
                reason: "Read-only tool has no direct write surface.",
            };
        }
        case "write_file": {
            const paths = extractWriteToolPaths(input.toolName, input.args);
            return {
                schema_version: 1,
                tool,
                enforceable: paths.length > 0,
                file_effect: "write",
                paths,
                reason: paths.length > 0
                    ? "Direct file-write tool exposes concrete target paths."
                    : "Direct file-write tool does not expose a concrete target path.",
            };
        }
        case "shell": {
            const analysis = analyzeShellCommand(extractCommandFromArgs(input.args));
            return {
                schema_version: 1,
                tool,
                enforceable: analysis.file_effect !== "unknown",
                file_effect: analysis.file_effect,
                paths: analysis.paths,
                reason: analysis.reason,
            };
        }
        case "seed_workspace": {
            const paths = extractWorkspaceToolPaths(tool.normalized_tool_name, input.args);
            return {
                schema_version: 1,
                tool,
                enforceable: true,
                file_effect: fileEffectFromPaths(paths),
                paths,
                reason: "SEED workspace tool exposes structured workspace path intent.",
            };
        }
        case "seed_coordination":
        case "seed_delegation":
        case "seed_evidence_capture":
            return {
                schema_version: 1,
                tool,
                enforceable: true,
                file_effect: "none",
                paths: [],
                reason: "SEED orchestration tool is policy-owned by the harness rather than a raw file mutation surface.",
            };
        case "seed_command_exec":
            return {
                schema_version: 1,
                tool,
                enforceable: false,
                file_effect: "unknown",
                paths: [],
                reason: "SEED command execution is stateful verification/background work and is reserved for Lab-Representative policy.",
            };
        case "mcp_or_external":
        case "unknown":
            return {
                schema_version: 1,
                tool,
                enforceable: false,
                file_effect: "unknown",
                paths: [],
                reason: "Tool side effects are not inspectable by the SEED hook classifier.",
            };
    }
}
function fileEffectFromPaths(paths) {
    if (paths.some((path) => path.access === "write"))
        return "write";
    if (paths.some((path) => path.access === "append"))
        return "append";
    if (paths.some((path) => path.access === "read"))
        return "read";
    return paths.length > 0 ? "unknown" : "none";
}
//# sourceMappingURL=hook-capability.js.map