/** * BSO M9 v0.3 — KernelAdapter 抽象(Layer 3) * * Refs: * - docs/prd/PRD-BSO-M9-HARNESS-HOOKS.md §3.4 * * 哲学转向:v0.2 是 "N harness × N adapter" 扁平设计;v0.3 改为 * "K 类机制内核 × N host 模板" 抽象 — 一类内核覆盖 N 个 host, * 新 host 95% 归入已有内核类别零额外开发。 * * P0 内核(M9): * - hook-file (Claude Code / Cursor 1.7+ / Windsurf) * - deny-pipeline (OpenClaw) * - mcp-only (Claude Desktop / 5ire / Tome / Witsy) * - protocol-reject (Layer 2 联动占位,无独立 install/uninstall) * * P1+ 内核(M9 之后):hook-executable / lifecycle-decorator / * filter-pipeline / memory-block / ...(详见 PRD §8)。 */ import type { Harness } from '../detector.js'; export type KernelType = 'hook-file' | 'deny-pipeline' | 'mcp-only' | 'protocol-reject'; /** * 候选 host 标识。注:不复用 Harness 类型 — 因为 mcp-only 内核覆盖了 * detector.ts 之前没有的 host(Claude Desktop / 5ire / Tome / Witsy)。 */ export type HostId = Harness | 'claude-desktop' | '5ire' | 'tome' | 'witsy'; export interface HostInfo { /** 命中的 host 名 */ host: HostId; /** 命中来源(detector / 用户 --host=... / mcp-only 全候选扫描)*/ source: 'detected' | 'forced' | 'scanned'; /** 可读提示(doctor 用) */ reason?: string; /** harness 版本,未知则 undefined */ version?: string; } export interface InstallContext { host: HostInfo; cwd: string; /** 写入是否真正落盘;false 时只 dry-run(doctor 用) */ apply: boolean; } export interface InstalledFile { /** 文件绝对路径 */ path: string; /** 操作类型 */ action: 'created' | 'merged' | 'already-registered' | 'replaced' | 'noop'; /** 备份路径(若有) */ backup?: string; /** 备注 */ details?: string; } export interface InstallResult { kernel: KernelType; host: HostId; /** 写入的文件清单 */ files: InstalledFile[]; /** 警告(不阻断 init) */ warnings: string[]; } export interface DiagnoseResult { kernel: KernelType; host: HostId; /** 该内核当前的强制力等级 */ level: 'strong' | 'protocol-fallback' | 'soft' | 'absent'; /** 子检查项(每条独立) */ checks: Array<{ name: string; ok: boolean; detail?: string; }>; } export interface KernelAdapter { kind: KernelType; /** 该 adapter 覆盖的所有 host */ supportedHosts: readonly HostId[]; /** 当前 host 是否归入该内核类别 */ matches(host: HostInfo): boolean; /** 安装:写入配置文件 + 注册 hooks/MCP/deny */ install(ctx: InstallContext): Promise; /** 卸载:恢复 .bak / 移除注册项 */ uninstall(ctx: InstallContext): Promise; /** 诊断:检查该 host 当前 install 状态 */ diagnose(ctx: InstallContext): Promise; } //# sourceMappingURL=types.d.ts.map