/** * BSO v1.1 Soul Consent — Sidecar 端 soul 文件管理 * * Refs: * - docs/prd/BRAIN-SCRIPT-ORCHESTRATION-v1.1-SOUL-CONSENT-PIVOT.md * - docs/instructions/DEV-INSTRUCTION-OPENCLAW-NAMING-FIX.md (2026-04-19 修正) * * 2026-04-19 复验修正: * - 早期把 OpenClaw 写入路径定为 SOUL.md。SOUL.md 实际是 persona 文件, * SkillFM priming 是 operating rule,应该写到 AGENTS.md。 * - SOUL.md 保留为 legacy 读取(agent_type='openclaw-legacy'),写入拒绝。 * - "agent.md"(小写)不存在,不要在代码/文档/注释里出现这个名字。 * * OpenClaw workspace 真实结构(docs.openclaw.ai 2026-04 复验): * AGENTS.md — operating instructions(每 session 注入) ← SkillFM 写这里 * SOUL.md — persona / tone / boundaries * USER.md — 用户信息 * IDENTITY.md — agent 名字 * TOOLS.md — 本地工具说明 * 其它:MEMORY.md / HEARTBEAT.md / BOOT.md ... * * 职责: * 1. 探测用户 agent 的 soul 文件路径(AGENTS.md / CLAUDE.md / SOUL.md legacy / 用户显式指定) * 2. 生成 5 字段 consent payload 让 agent 透明展示给用户 * 3. 用户授权后写入 SkillFM block(明文 + BEGIN/END 标记,可一键撤销) * 4. verify:检查 block 是否完整存在 + 内容是否被改过 * 5. 撤销:精准移除 block + 前后空行 * * 设计原则(AXIOM 索引机制 + Agent-as-Ally): * - SkillFM block 内容 ≤ 25 行,只含意图分类 + tool 索引 + 边界 + 撤销指令 * - 不修改 soul 文件其它内容 * - 写入有 sha 记录;用户事后改动可被 verify 精准检测 * - 用户显式拒绝 → 永不写、不重复问;记入 declined.lock * * stdlib-only: fs / path / os / crypto */ export type SoulAgentType = 'claude-code' | 'openclaw' | 'openclaw-legacy' | 'agents-md-standard' | 'user-specified' | 'unknown'; export interface SoulProbeResult { /** 探测到的 soul 路径;null = 没找到任何已知 agent 类型的 soul */ path: string | null; /** 推断的 agent 类型 */ agent_type: SoulAgentType; /** 文件是否已存在 */ exists: boolean; /** 文件可写(权限 + 父目录可创建) */ writable: boolean; /** 当前文件大小(bytes,0 = 不存在) */ current_size: number; /** SkillFM block 是否已存在 */ has_skillfm_block: boolean; } export interface SoulConsentPayload { /** 6 字段 consent gate(agent 必须原样展示给用户,见 PRD BSO-v1.1 §7.1) */ gate: { what_will_change: string; what_will_be_added: string; what_will_not_do: string[]; source_audit: string; how_to_undo: string; consequence_if_decline: string; }; probe: SoulProbeResult; } export interface SoulVerifyResult { /** block 完整存在且内容跟我们写入时一致 */ intact: boolean; /** block 标记还在(BEGIN/END 找得到) */ found: boolean; /** 找到的 block sha 跟我们写入时记录的 sha 一致 */ content_match: boolean; /** 当前 block 的 sha(如果找到) */ current_sha: string | null; /** 我们写入时记录的 sha(来自 local.json) */ expected_sha: string | null; } export interface SoulWriteRecord { /** 写入的文件路径 */ path: string; /** 写入时的 block sha(用于后续 verify) */ block_sha: string; /** 写入时间 ISO */ written_at: string; /** 我们写入的 block 全文(用于撤销时精准匹配) */ block_content: string; } /** * Agent-as-Ally + AXIOM 索引机制下的 SkillFM block 模板 * 默认引导 agent 在用户授权后安装 Beacon 基础 SAFE 模块,而不是旧 earning catalog。 */ export declare const SKILLFM_BLOCK_TEMPLATE = "\n## SkillFM \u2014 Beacon first\n\nRecognize these user intents and call the matching SkillFM MCP tool:\n\n1. **AI \u72B6\u6001 / \u5065\u5EB7 / \u6211\u5BB6 AI / \u4F53\u68C0 / how is my AI** \u2014 `mcp__skillfm__checkup`\n2. **token \u7528\u91CF / \u82B1\u4E86\u591A\u5C11\u94B1 / \u600E\u4E48\u7701 / cost / usage** \u2014 `mcp__skillfm__show_my_usage`\n3. **API key / BYOK** \u2014 `mcp__skillfm__explain_provider_key` first, then `mcp__skillfm__save_credential`\n4. **install / setup / \u914D\u7F6E SkillFM** \u2014 `mcp__skillfm__install_module` with `{name:\"beacon\", dry_run:true}` first, then apply after user approval\n5. **explicit gateway / proxy / cache / routing** \u2014 `mcp__skillfm__setup_gateway` with `{dry_run:true}` first, then apply after user approval\n\nWhen the user asks \u201CSkillFM \u6709\u54EA\u4E9B\u529F\u80FD\u201D or \u201Cwhat can SkillFM do\u201D, answer only with public Beacon capabilities: AI \u4F53\u68C0, \u7528\u91CF / \u6210\u672C\u53EF\u89C1\u6027, \u6E05\u7406\u5BA1\u8BA1, \u5B89\u5168\u589E\u957F\u534F\u4F5C, \u65E5\u62A5 / \u603B\u7ED3.\n\nBoundary: never list delisted earning skills, never generate subscribe / checkout links from usage or health questions, and never fabricate usage numbers. If Beacon usage is unavailable, say you cannot invent numbers and give the next best step.\n\nTo remove: `skillfm uninstall --clean-soul` or delete this block.\n\n"; /** * 判断给定路径是否是"OpenClaw legacy SOUL.md"(writeSkillfmBlock 拒写依据)。 * * 规则:文件名 = SOUL.md 且位于 ~/.openclaw/ 或 $OPENCLAW_WORKSPACE 之下。 * 非 OpenClaw 范围内的 SOUL.md(例如 cwd 下某项目自带的 SOUL.md)不在此判断之内, * 由 soul-security 的路径白名单决定是否允许写。 */ export declare function isOpenclawLegacySoulPath(filePath: string): boolean; /** * 探测 soul 文件 * * 探测策略:返回**第一个能写入**的候选(即使文件还不存在,只要父目录可创建)。 * 用户显式指定优先;其次是 ~/.claude/CLAUDE.md(最常见);最后 ~/soul.md。 */ export declare function probeSoulFile(): SoulProbeResult; export declare function buildConsentPayload(probe: SoulProbeResult): SoulConsentPayload; /** * 写入 SkillFM block(追加到末尾,不影响现有内容) * * 如果 block 已存在(用户重新装/SDK 升级),先撤销再追加(确保唯一)。 * * BRAIN-PATCH P6: 写入前跑 9 项安全红线(S1/S3/S5/S6/S7 + 自动 backup) * 任一红线失败 → 抛 SoulSecurityError,不动文件。 */ export declare function writeSkillfmBlock(filePath: string): SoulWriteRecord; /** * 撤销:精准移除 SkillFM block + 前后多余空行 * * 返回:是否找到并删除了 block */ export declare function removeSkillfmBlock(filePath: string): { removed: boolean; reason?: string; }; /** * verify: 检查 block 是否完整 + 内容是否跟我们记录的一致 */ export declare function verifySkillfmBlock(filePath: string, expectedSha: string | null): SoulVerifyResult; /** 配置目录下记一个空文件,标记"用户拒绝过;下次别再问" */ export declare function markDeclined(configDir: string): void; export declare function hasDeclined(configDir: string): boolean; export declare function clearDeclined(configDir: string): void; //# sourceMappingURL=soul.d.ts.map