mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-17 11:51:39 +00:00
* fix(infra): preserve bounded response text characters Co-authored-by: qingminlong <34085845+qingminglong@users.noreply.github.com> * ci(plugin-sdk): refresh API baseline --------- Co-authored-by: qingminlong <34085845+qingminglong@users.noreply.github.com>
13 lines
585 B
TypeScript
13 lines
585 B
TypeScript
export type DecodeTextPrefixOptions = {
|
|
encoding?: string;
|
|
truncated?: boolean;
|
|
};
|
|
|
|
/** Decodes a byte prefix without inventing a replacement character for a cut trailing sequence. */
|
|
export function decodeTextPrefix(bytes: Uint8Array, options: DecodeTextPrefixOptions = {}): string {
|
|
const decoder = new TextDecoder(options.encoding);
|
|
// Streaming mode retains an incomplete tail; discarding this one-shot decoder
|
|
// drops only that cut sequence while complete bodies still flush normally.
|
|
return decoder.decode(bytes, options.truncated ? { stream: true } : undefined);
|
|
}
|