Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Merge #6676 follow-up commits
milind-sonif7f62c48b1b6
diff --cc src/components/ChatMarkdown.tsxindex 1e64a4cf38,6bd6e60505..48ceb39d45--- a/src/components/ChatMarkdown.tsx+++ b/src/components/ChatMarkdown.tsx@@@ -155,16 -155,18 +155,21 @@@ function unwrapLinkedImages()// directions falls back to LTR. JS regexes cannot match Bidi_Class, so these are the blocks Unicode reserves for// right-to-left letters.const RTL_LETTER = /[\u0590-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFF\u{10800}-\u{10FFF}\u{1E800}-\u{1EFFF}]/u;- /** A bare address is Latin whatever language the sentence around it is in, so its letters are not counted. */- const ADDRESS = /(?:[a-z][a-z0-9+.-]*:\/\/|www\.)\S+/giu;+ const ADDRESS = /(?:[a-z][a-z0-9+.-]*:\/\/|www\.)[^\s\u0590-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFF()]+/giu;+ const TECHNICAL = /[\d._/\\@=]|^-|\p{Ll}\p{Lu}/u;- /** The script with more letters decides; the first letter only breaks a tie. An Arabic answer often opens on a name- * ("Chrome 158" or "**Node.js**" then Arabic), and the first letter alone laid that whole paragraph or list out- * left-to-right: the Arabic words, numbers and Latin names in it reordered, and its bullets went left. */++/** The script with more words decides; the first word only breaks a tie. Addresses, numbers and code-like tokens are++ * not counted. An Arabic answer often opens on a name ("Chrome 158" or "**Node.js**" then Arabic), and the first letter++ * alone laid that whole paragraph or list out left-to-right. */export function textDirection(value: string): "rtl" | "ltr" {+ const text = value.replace(ADDRESS, " ");let rtl = 0, ltr = 0, first: "rtl" | "ltr" | null = null;- for (const [letter] of value.replace(ADDRESS, " ").matchAll(/\p{Letter}/gu)) {- const direction = RTL_LETTER.test(letter) ? "rtl" : "ltr";+ for (const raw of text.split(/\s+/)) {+ const word = raw.replace(/[.,;:!?]+$/u, "");+ const direction = [...word].some((char) => RTL_LETTER.test(char) && /\p{Letter}/u.test(char)) ? "rtl"+ : /\p{Letter}/u.test(word) && !TECHNICAL.test(word) ? "ltr"+ : null;+ if (!direction) continue;first ??= direction;if (direction === "rtl") rtl += 1;else ltr += 1;