/** * 模块: 会话回顾(Session Recap)— 对齐 Claude Code 75-min idle auto-summary * * 触发条件(AND): * 1. before_prompt_build 看到当前 agent/session 的上一次活动距现在 > recapIdleMinutes(默认 75) * 2. 距离上次 recap 已超过 recapMinIntervalMinutes(默认 30)或本进程内从未 recap 过此 agent * * 恢复内容(prependContext 里追加): * - 最近 1 个章节(title + summary) * - 最近 3 条 in_progress/pending todo * - 最近 2 条 decision 类记忆 * - 一句"你刚回来,上次到这儿"的引导 * * 非侵入式保证: * - 只读三张已有表(chapters / todos / memories),不建新表 * - 纯追加 prependContext,绝不覆盖龙虾原生 system prompt * - 可通过 config.sessionRecap.enabled = false 关闭 * - 同时提供 enhance_session_recap 工具,用户可手动"给我做个回顾" */ import type { OpenClawPluginApi } from "openclaw/plugin-sdk"; import { getDb } from "../utils/sqlite-store.js"; export interface SessionRecapConfig { enabled?: boolean; /** 距上次活动多久(分钟)就认为是 idle,默认 75 */ recapIdleMinutes?: number; /** 两次 recap 的最小间隔(分钟),防抖,默认 30 */ recapMinIntervalMinutes?: number; /** recap 里章节数,默认 1 */ maxChapters?: number; /** recap 里 todo 数,默认 3 */ maxTodos?: number; /** recap 里 decision 记忆数,默认 2 */ maxDecisions?: number; } /** * 构建一次 recap 文本;若没有任何素材返回空串(调用方可据此决定是否注入)。 */ export declare function buildRecapText(db: ReturnType, agentId: string, sessionId: string, cfg: Required>, idleMs: number): string; export declare function registerSessionRecap(api: OpenClawPluginApi, config?: SessionRecapConfig): void;