/** * 工作区完整性检查 — 从 middleware.ts 抽出的独立关切。 * * 职责边界: * - 负责:IOController 工作区脏数据检测 + denied_paths 写入路径黑名单 * - 不负责:合同授权、预算检查 * * 被谁调用:middleware.performToolCall(仅当 hasWriteEffect=true) * 调用谁:IOController.verify / shared.denied_paths * * 数据流:(toolName, args, projectPath) → { violation?, warning? } * 持久化:无 * * 工作区有外部变更时硬阻断;命中 denied_paths 时同样硬阻断。 */ import type { IOController } from "../../../shared/io_controller.js"; import type { ToolInvocationViolation } from "../../../gate/index.js"; import type { ToolRequestArgs } from "../types.js"; /** 工作区检查结果 */ export interface WorkspaceCheckResult { /** hard_fail 违规(脏数据或 denied_path 时存在) */ violation?: ToolInvocationViolation; /** 降级放行时的警告(IOController 异常) */ warning?: string; /** violation 携带的额外响应字段 */ extraResponseFields?: Record; } /** * 检查工作区完整性 — 写入操作前确保无外部变更。 * * @param toolName 工具名 * @param invocationId 调用 ID * @param _taskId 任务 ID(保留用于 violation 关联,未来扩展用) * @param ioController IO 控制器 * @param sideEffects 当前副作用列表(用于构建 violation trace) */ export declare function checkWorkspaceIntegrity(toolName: string, invocationId: string, _taskId: string | undefined, ioController: IOController): Promise; /** * 检查 denied_paths — 写入路径黑名单。 * * @param toolName 工具名 * @param invocationId 调用 ID * @param args 工具参数(从中提取 file_path/path/target_path 等字段) * @param projectPath 项目根路径(用于 path.relative) */ export declare function checkDeniedPaths(toolName: string, invocationId: string, args: ToolRequestArgs, projectPath: string): WorkspaceCheckResult;