* 销毁上下文组件
()
| 117 | * 销毁上下文组件 |
| 118 | */ |
| 119 | public async destroy(): Promise<void> { |
| 120 | if (!this.isReady) { |
| 121 | return; |
| 122 | } |
| 123 | |
| 124 | this.log('销毁上下文组件...'); |
| 125 | |
| 126 | try { |
| 127 | if (this.contextManager) { |
| 128 | await this.contextManager.cleanup(); |
| 129 | this.contextManager = undefined; |
| 130 | } |
| 131 | |
| 132 | this.currentSessionId = undefined; |
| 133 | this.isReady = false; |
| 134 | this.log('上下文组件已销毁'); |
| 135 | } catch (error) { |
| 136 | this.log(`销毁上下文组件时出错: ${error}`); |
| 137 | } |
| 138 | } |
| 139 | |
| 140 | /** |
| 141 | * 创建新会话 |