(chatKey: string)
| 233 | } |
| 234 | |
| 235 | private async ensureCtxChat(chatKey: string): Promise<CtxChatState> { |
| 236 | this.ensureReady(); |
| 237 | const key = this.gk(chatKey); |
| 238 | |
| 239 | await this.dbCtx.read(); |
| 240 | this.dbCtx.data ||= { chats: {} }; |
| 241 | this.dbCtx.data.chats ||= {}; |
| 242 | |
| 243 | if (!this.dbCtx.data.chats[key]) { |
| 244 | this.dbCtx.data.chats[key] = this.normalizeCtxState({ contextEnabled: false, contextTurns: {} }); |
| 245 | await this.dbCtx.write(); |
| 246 | } else { |
| 247 | this.dbCtx.data.chats[key] = this.normalizeCtxState(this.dbCtx.data.chats[key]); |
| 248 | } |
| 249 | return this.dbCtx.data.chats[key]; |
| 250 | } |
| 251 | |
| 252 | async getChatState(chatKey: string): Promise<ChatState> { |
| 253 | this.ensureReady(); |
no test coverage detected