/** * Streaming parser that splits `` (and ``) * tags embedded in a model's text output into separate text / thinking segments. * * Problem: reasoning models like nemotron, deepseek-r1, qwq emit their chain of * thought inline in the text content field — not via the Anthropic `thinking` * block nor the OpenAI `reasoning_content` field. If we don't split these, * the literal `` tags and the full reasoning leak into the answer UI * and into conversation history (wasting context on future turns). * * Usage: * const s = new ThinkTagStripper(); * for (const seg of s.push(chunk)) emit(seg); * for (const seg of s.flush()) emit(seg); * * Handles tags split across chunk boundaries by holding a small suffix. */ export type Segment = { type: 'text' | 'thinking'; text: string; }; export declare class ThinkTagStripper { private mode; private pending; push(chunk: string): Segment[]; flush(): Segment[]; }