conversation-recovery
Capture and recover conversation state across OpenClaw sessions.
Description
This skill provides conversation state management and recovery capabilities for OpenClaw. When conversations get interrupted or span multiple sessions, it captures the essential context (intents, facts, tasks) and allows seamless recovery.
Use Cases
- - Long-running tasks: Save progress when a conversation spans multiple days
- Context restoration: Recover where you left off after interruptions
- Session handoff: Transfer context between different channels/platforms
- Memory management: Archive old sessions while preserving key information
Installation
CODEBLOCK0
Core Concepts
Session
A conversation container with metadata (status, channel, timestamps).
Snapshot
A point-in-time capture of conversation state containing:
- - Intents: What the user wants to accomplish
- Facts: Established information and preferences
- Tasks: Action items and their status
Recovery
Restoring context from a snapshot to continue a conversation seamlessly.
API Usage
Starting a Session
CODEBLOCK1
Capturing a Snapshot
CODEBLOCK2
Recovering a Session
CODEBLOCK3
Managing Sessions
CODEBLOCK4
Storage Operations
CODEBLOCK5
Data Models
Session
CODEBLOCK6
Snapshot
CODEBLOCK7
Intent
CODEBLOCK8
Fact
CODEBLOCK9
Task
CODEBLOCK10
Storage
Data is stored in JSON files at:
- - Sessions: INLINECODE0
- Snapshots: INLINECODE1
Override with environment variable:
CODEBLOCK11
Roadmap
Phase 1 (Current)
- - ✅ Core data models (Session, Snapshot, Intent, Fact, Task)
- ✅ File storage layer (CRUD operations)
- ✅ Basic session lifecycle management
- ✅ Recovery summary generation
Phase 2 (Planned)
- - Intent extraction from conversation text
- Automatic snapshot triggers (token limits, time intervals)
- Compression and summarization of old snapshots
Phase 3 (Planned)
- - Vector search for similar past sessions
- Cross-session knowledge graph
- Integration with OpenClaw memory system
License
MIT
conversation-recovery
跨OpenClaw会话捕获和恢复对话状态。
描述
该技能为OpenClaw提供对话状态管理和恢复能力。当对话被中断或跨越多个会话时,它能捕获关键上下文(意图、事实、任务)并实现无缝恢复。
使用场景
- - 长期任务:在对话跨越数天时保存进度
- 上下文恢复:中断后恢复之前的对话位置
- 会话交接:在不同频道/平台间传递上下文
- 内存管理:归档旧会话同时保留关键信息
安装
bash
依赖通过package.json管理
npm install
构建TypeScript
npm run build
核心概念
会话
包含元数据(状态、频道、时间戳)的对话容器。
快照
对话状态的即时捕获,包含:
- - 意图:用户想要完成的目标
- 事实:已确认的信息和偏好
- 任务:待办事项及其状态
恢复
从快照中还原上下文,无缝继续对话。
API使用
启动会话
typescript
import { startSession } from conversation-recovery;
const session = await startSession(
项目规划讨论,
discord
);
捕获快照
typescript
import { captureSnapshot } from conversation-recovery;
const snapshot = await captureSnapshot(session.id, {
description: 用户想要规划Q3路线图,
intents: [{
id: intent_1,
description: 创建Q3产品路线图,
confidence: 0.95,
fulfilled: false,
createdAt: new Date().toISOString()
}],
facts: [{
id: fact_1,
statement: 团队有5名可用工程师,
category: constraint,
confidence: 1.0,
active: true,
createdAt: new Date().toISOString()
}],
tasks: [{
id: task_1,
description: 收集利益相关者的需求,
status: pending,
priority: high,
relatedIntentIds: [intent_1],
dependencies: [],
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString()
}]
});
恢复会话
typescript
import { recoverSession } from conversation-recovery;
const recovery = await recoverSession(session.id);
// 返回包含关键意图、事实、任务和建议的RecoverySummary
管理会话
typescript
import {
pauseSession,
resumeSession,
archiveSession,
getActiveSessions,
deleteSession
} from conversation-recovery;
await pauseSession(session.id); // 标记为暂停
await resumeSession(session.id); // 标记为活跃
await archiveSession(session.id); // 标记为已归档
await deleteSession(session.id); // 永久删除
const active = await getActiveSessions();
存储操作
typescript
import {
getSession,
getSnapshot,
getSessionSnapshots,
getLatestSnapshot,
deleteSnapshot,
listSessions,
getStorageStats,
cleanupSnapshots
} from conversation-recovery;
const session = await getSession(sessionId);
const snapshot = await getSnapshot(snapshotId);
const snapshots = await getSessionSnapshots(sessionId);
const latest = await getLatestSnapshot(sessionId);
const allSessions = await listSessions();
const stats = await getStorageStats();
// 仅保留最后10个快照
await cleanupSnapshots(sessionId, 10);
数据模型
会话
typescript
interface Session {
id: string;
createdAt: string;
updatedAt: string;
title?: string;
channel?: string;
status: active | paused | recovered | archived;
snapshots: string[];
}
快照
typescript
interface Snapshot {
id: string;
sessionId: string;
createdAt: string;
description?: string;
intents: Intent[];
facts: Fact[];
tasks: Task[];
context?: string;
tokenCount?: number;
}
意图
typescript
interface Intent {
id: string;
description: string;
confidence: number;
sourceMessageId?: string;
fulfilled: boolean;
createdAt: string;
}
事实
typescript
interface Fact {
id: string;
statement: string;
category: preference | constraint | context | decision | requirement;
sourceMessageId?: string;
confidence: number;
active: boolean;
createdAt: string;
}
任务
typescript
interface Task {
id: string;
description: string;
status: pending | in_progress | blocked | completed | cancelled;
priority: low | medium | high | critical;
relatedIntentIds: string[];
dependencies: string[];
dueDate?: string;
createdAt: string;
updatedAt: string;
}
存储
数据以JSON文件存储于:
- - 会话:~/.openclaw/conversation-recovery/sessions/
- 快照:~/.openclaw/conversation-recovery/snapshots/
通过环境变量覆盖:
bash
export CONVERSATIONRECOVERYSTORAGE=/custom/path
路线图
第一阶段(当前)
- - ✅ 核心数据模型(会话、快照、意图、事实、任务)
- ✅ 文件存储层(CRUD操作)
- ✅ 基本会话生命周期管理
- ✅ 恢复摘要生成
第二阶段(计划中)
- - 从对话文本中提取意图
- 自动快照触发(令牌限制、时间间隔)
- 旧快照的压缩和摘要
第三阶段(计划中)
- - 相似历史会话的向量搜索
- 跨会话知识图谱
- 与OpenClaw内存系统集成
许可证
MIT