refactor: modularize portal server and harden session recovery

This commit is contained in:
john
2026-07-24 18:39:24 +08:00
parent 1d291fd528
commit 785731d98d
109 changed files with 29185 additions and 5836 deletions
+3
View File
@@ -8,6 +8,8 @@ import { stripKnownChatSkillPrompt } from './chat-skills.mjs';
export const TASK_ROUTING_HINT_RE = /^【TKMind 路由提示】[\s\S]*?\n\n/;
export const MEMIND_TASK_ORCHESTRATION_RE = /^【Memind 任务编排】[\s\S]*?(?:用户任务:|用户任务:)\s*/u;
export const MINDSPACE_CONTEXT_RE = /^\[MindSpace 上下文\][\s\S]*?\n\n/;
export const IMAGE_TURN_SCOPE_SUFFIX_RE =
/\n*【本轮图片主题(硬性)】[\s\S]*$/u;
const USER_IDENTITY_BLOCK_RE = /^\[用户身份\][\s\S]*?\n\n/;
export function stripUserIdentityPrefix(text) {
@@ -63,6 +65,7 @@ export function deriveAssistantFacingText(text) {
/** Strip agent-only prefixes from persisted user message content for UI display. */
export function deriveUserFacingText(text) {
let next = String(text ?? '');
next = next.replace(IMAGE_TURN_SCOPE_SUFFIX_RE, '');
next = stripUserIdentityPrefix(next);
next = stripTaskRoutingHint(next);
next = stripMemindTaskOrchestrationPrefix(next);