Connection
Base URL, credentials and a reachable server.
Split a bot’s outgoing text at the configured UTF-16 length limit without separating a surrogate pair. Check an emoji at the boundary, an empty message and fenced code, preserving the text when the chunks are joined.
Base URL, credentials and a reachable server.
A model available through the configured endpoint.
Context limits and tool support are determined by the model and server.
if (!Number.isInteger(start) || start < 0 || start > text.length) {
throw new Error("start.invalid");
}
if (!Number.isInteger(limit) || limit < 1) throw new Error("limit.invalid");
if (start === text.length) return "";
let end = Math.min(start + limit, text.length);
const last = text.charCodeAt(end - 1);
if (end < text.length && last >= 0xD800 && last <= 0xDBFF) end--;
if (end === start) throw new Error("limit.too_small");
return text.slice(start, end);