feat(characters): support character-scoped conversations

This commit is contained in:
2026-07-17 11:42:31 +08:00
parent 93efcb6604
commit 2796010971
85 changed files with 1645 additions and 251 deletions
+14 -5
View File
@@ -36,18 +36,20 @@ export class ChatRepository implements IChatRepository {
/** 发送一条消息。 */
async sendMessage(
characterId: string,
message: string,
options?: { image?: string; useWebSocket?: boolean },
): Promise<Result<ChatSendResponse>> {
return this.remote.sendMessage(message, options);
return this.remote.sendMessage(characterId, message, options);
}
/** 获取聊天历史,分页参数默认 limit=50, offset=0。 */
async getHistory(
characterId: string,
limit = 50,
offset = 0,
): Promise<Result<ChatHistoryResponse>> {
return this.remote.getHistory(limit, offset);
return this.remote.getHistory(characterId, limit, offset);
}
/** 解锁单条历史付费 / 私密消息。 */
@@ -58,8 +60,8 @@ export class ChatRepository implements IChatRepository {
}
/** 一键解锁历史锁定消息。 */
async unlockHistory(): Promise<Result<UnlockHistoryResponse>> {
return this.remote.unlockHistory();
async unlockHistory(characterId: string): Promise<Result<UnlockHistoryResponse>> {
return this.remote.unlockHistory(characterId);
}
/** 把本地缓存中的单条锁定消息标记为已解锁。 */
@@ -133,17 +135,24 @@ export class ChatRepository implements IChatRepository {
async prefetchMediaForMessages(
messages: readonly ChatMessage[],
characterId: string,
cacheIdentity?: string,
): Promise<Result<void>> {
return this.mediaCache.prefetchMediaForMessages(messages, cacheIdentity);
return this.mediaCache.prefetchMediaForMessages(
messages,
characterId,
cacheIdentity,
);
}
async prefetchMediaForSendResponse(
response: ChatSendResponse,
characterId: string,
cacheIdentity?: string,
): Promise<Result<void>> {
return this.mediaCache.prefetchMediaForSendResponse(
response,
characterId,
cacheIdentity,
);
}