UNPKG

braiin

Version:

Behavioral Reasoning AI for Intelligent Navigation

19 lines (18 loc) 977 B
export declare const STREAM_END_MARKER = "[[END]]"; /** * Builds a stateful delta filter that streams the value of the top-level * `"answer"` key of a `finish` action, decoding JSON string escapes on the fly. * * The model keeps emitting strict JSON (`{"action":"finish","answer":"..."}`), * so `enforceJsonOutput` can stay ON — there is no plain-text "tail" format and * no way for protocol JSON or reasoning to leak into the stream: only the * characters inside the `answer` string are forwarded to `onToken`, as soon as * each delta arrives (the only buffered part is the `{"action":..,"answer":"` * envelope prefix). * * Steps without a top-level `answer` key (describe/call/abort) emit nothing, * which makes the filter self-gating across the whole reasoning chain. * * Create a fresh filter per LLM call — state is not meant to be reused. */ export declare const createAnswerStreamFilter: (onToken: (token: string) => void) => (delta: string) => void;