Files
Jyotisha/frontend/src/lib/think-step-gate.ts
T
jesse-ux cd4775aec6 fix(consult): BUG-950~953 Pass 4 按句放行,无分钟按句丢弃
正文不再整段 hold:闭合句立刻过 Pass 4,无 reject 即发(950)。
无出生分钟改为按句丢弃,全丢才用兜底句(951);该模式日期记 observe(952)。
校正流 token 级 thinking 死链按 P2 删除,测试翻转成否定合同(953)。
2026-09-18 14:08:45 +08:00

18 lines
639 B
TypeScript

/**
* Pass 2 public thinking is a complete product sentence, never a CoT fragment.
* This gate only accepts or rejects. It must not rewrite, strip, or splice.
*/
const CJK_RE = /[\u4e00-\u9fff]/;
const SENTENCE_RE = /[。!?]/;
export const THINK_STEP_TEXT_MIN = 8;
export const THINK_STEP_TEXT_MAX = 400;
export function acceptThinkStepText(text: string): string | null {
const trimmed = text.replace(/\s+/g, " ").trim();
if (trimmed.length < THINK_STEP_TEXT_MIN || trimmed.length > THINK_STEP_TEXT_MAX) return null;
if (!CJK_RE.test(trimmed)) return null;
if (!SENTENCE_RE.test(trimmed)) return null;
return trimmed;
}