/** * detect-polling.ts — 容器环境检测与 polling 降级判断(Phase 2A) * * 在 Docker / Kubernetes / WSL2 等容器或虚拟化环境中, * `fs.watch`(基于 inotify / FSEvents / ReadDirectoryChangesW)可能无法 * 正确检测 bind mount 挂载卷上的文件变更。 * * 此模块自动检测运行环境,决定是否需要降级为 polling 模式: * * | 环境 | 监听方式 | 配置方式 | * |---------------------------|-----------|--------------------------| * | macOS / Windows / Linux | fs.watch | 默认即可 | * | Docker (bind mount) | polling | 自动检测或 VEXT_DEV_POLL=1 | * | Docker (volume) | fs.watch | 默认即可 | * | WSL2 (跨文件系统) | polling | VEXT_DEV_POLL=1 | * * 检测优先级: * 1. 环境变量 VEXT_DEV_POLL 显式设置 → 使用设置值 * 2. 检测到容器 + bind mount → 使用 polling * 3. 默认不使用 polling(fs.watch 通常可靠) * * @module lib/dev/detect-polling * @see 11c-file-watcher.md §5(自动检测容器环境) * @see IMPLEMENTATION-PLAN.md 任务 2.3 */ /** * shouldUsePolling — 判断是否需要使用 polling 模式 * * @returns true 表示应使用 polling,false 表示使用 fs.watch */ export declare function shouldUsePolling(): boolean; /** * isInContainer — 检测当前进程是否运行在容器内 * * 检测方法(按可靠性排序): * 1. /.dockerenv 文件存在 → Docker 容器 * 2. /proc/1/cgroup 包含 docker/kubepods/containerd 关键字 → 容器运行时 * * 注意:这些检测方法可能在某些非标准容器运行时中失效, * 但覆盖了绝大多数用户场景(Docker、Docker Compose、Kubernetes)。 * * @returns true 表示在容器内 */ export declare function isInContainer(): boolean; /** * checkBindMount — 检查工作目录是否为 bind mount * * bind mount 的文件系统通常是 ext4/xfs/ntfs 等宿主机类型, * 而非 overlay(Docker 层文件系统)。 * bind mount 上 inotify 不工作是 Linux 内核已知限制。 * * 检测方法: * 读取 /proc/mounts,检查当前工作目录或 /app 挂载点 * 是否使用非 overlay 文件系统。 * * @returns true 表示检测到 bind mount(应使用 polling) */ export declare function checkBindMount(): boolean;