MCPcopy Create free account
hub / github.com/TeleBoxOrg/TeleBox_Plugins / ensureCtxChat

Method ensureCtxChat

deepwiki/deepwiki.ts:235–250  ·  view source on GitHub ↗
(chatKey: string)

Source from the content-addressed store, hash-verified

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();

Callers 6

getChatStateMethod · 0.95
deleteRepoMethod · 0.95
setContextEnabledMethod · 0.95
clearContextMethod · 0.95
appendTurnMethod · 0.95
getTurnsMethod · 0.95

Calls 4

ensureReadyMethod · 0.95
gkMethod · 0.95
normalizeCtxStateMethod · 0.95
writeMethod · 0.80

Tested by

no test coverage detected