* 初始化上下文管理器
()
| 65 | * 初始化上下文管理器 |
| 66 | */ |
| 67 | async initialize(): Promise<void> { |
| 68 | if (this.initialized) return; |
| 69 | |
| 70 | try { |
| 71 | await this.persistent.initialize(); |
| 72 | |
| 73 | // 检查存储健康状态 |
| 74 | const health = await this.persistent.checkStorageHealth(); |
| 75 | if (!health.isAvailable) { |
| 76 | console.warn('警告:持久化存储不可用,将仅使用内存存储'); |
| 77 | } |
| 78 | |
| 79 | this.initialized = true; |
| 80 | console.log('上下文管理器初始化完成'); |
| 81 | } catch (error) { |
| 82 | console.error('上下文管理器初始化失败:', error); |
| 83 | throw error; |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | /** |
| 88 | * 创建新会话 |