import fs from "node:fs"; import { type DiagnosticEvent } from "../diagnostics/error-codes.js"; /** * Session root 注册与路径策略(roadmap §4.2)。 */ export type SessionRootSource = "agent-dir" | "runtime-session-dir" | "user-added"; export interface SessionRoot { id: string; path: string; source: SessionRootSource; enabled: boolean; } export interface RootRegistry { roots: SessionRoot[]; } /** * 规范化 root 路径:resolve → realpath(不存在则回退)→ win32 小写。 */ export declare function canonicalizeRootPath(input: string): string; /** * 由路径生成稳定 user root ID(全路径 sha256 前 32 hex)。 */ export declare function rootIdForPath(input: string): string; /** * 是否为 1.0.0 碰撞易发的旧 user root ID。 */ export declare function isLegacyUserRootId(id: string): boolean; /** * 路径是否相等(win32 大小写不敏感)。 */ export declare function pathsEqual(a: string, b: string): boolean; /** * 文件是否落在 root 目录下(win32 大小写不敏感)。 */ export declare function isPathUnderRoot(filePath: string, rootPath: string): boolean; /** * 创建 root registry。 */ export declare function createRootRegistry(roots: SessionRoot[]): RootRegistry; /** * 路径是否落在已启用的注册 root 内。 */ export declare function isPathInsideRoots(filePath: string, registry: RootRegistry): boolean; /** * 校验历史文件是否允许只读打开:必须是 regular、非 symlink。 */ export declare function assertReadableSessionFile(filePath: string, registry: RootRegistry, existsSync?: typeof fs.existsSync, lstatSync?: typeof fs.lstatSync): { ok: true; } | { ok: false; diagnostic: DiagnosticEvent; }; //# sourceMappingURL=root-registry.d.ts.map