export type DirectorySource = 'explicit' | 'alias' | 'chat_default' | 'env_default' | 'server_default'; export type DirectoryErrorCode = 'empty' | 'not_absolute' | 'path_too_long' | 'dangerous_path' | 'not_allowed' | 'explicit_requires_allowlist' | 'alias_not_found' | 'not_found' | 'not_directory' | 'not_accessible' | 'realpath_not_allowed' | 'git_root_not_allowed' | 'git_root_invalid'; export interface DirectoryResolved { ok: true; directory: string; source: DirectorySource; raw: string; normalized: string; realpath: string; gitRoot?: string; projectName?: string; } export interface DirectoryResolveError { ok: false; code: DirectoryErrorCode; userMessage: string; internalDetail?: string; source?: DirectorySource; raw?: string; } export type DirectoryResolveResult = DirectoryResolved | DirectoryResolveError; /** * 约束作用域: * - 'platform'(默认):平台接入(telegram/discord/qq/wecom/weixin/whatsapp/dingtalk/feishu/group/p2p * 以及 /send 文件下发)必须强制 ALLOWED_DIRECTORIES 白名单,因为路径来自外部消息输入,不可信。 * - 'workspace':AI 工作区(Web 管理面板内的文件树 / Git / 终端 / 新建项目对话框)。 * 调用方已通过管理面板身份认证,白名单和默认工作目录对其不适用 —— 只保留 * 格式校验、危险路径拦截、存在性/可访问性检查以及 realpath 规范化。 * * 变更点:白名单与默认工作目录仅约束平台接入,与 AI 工作区权限脱钩。 */ export type DirectoryPolicyScope = 'platform' | 'workspace'; interface DirectoryResolveOptions { explicitDirectory?: string; aliasName?: string; chatDefaultDirectory?: string; envDefaultDirectory?: string; serverDefaultDirectory?: string; projectAliases?: Record; allowedDirectories?: string[]; gitRootNormalization?: boolean; maxPathLength?: number; /** * 作用域,默认 'platform'。AI 工作区请传 'workspace' 以脱钩白名单约束。 */ scope?: DirectoryPolicyScope; } export declare class DirectoryPolicy { private static detectAllowlistConfigMode; private static buildAllowlistGuidance; private static buildAllowlistUserMessage; static buildProjectListEmptyMessage(): string; static resolve(options?: DirectoryResolveOptions): DirectoryResolveResult; static listAvailableProjects(knownDirectories: string[]): Array<{ name: string; directory: string; source: DirectorySource; }>; static isAllowedPath(targetPath: string, allowedDirectories?: string[]): boolean; private static normalizePath; private static getComparablePath; private static normalizeAllowedDirectories; private static isDangerousPath; private static isPathAllowed; private static ensureAccessible; private static detectGitRoot; } export {}; //# sourceMappingURL=directory-policy.d.ts.map