Something went wrong. Try again.
Where attention appears to go across agent threads: collector, web explorer, and native iOS client
Something went wrong. Try again.
12345678910111213141516171819202122232425262728// @ts-check/** @typedef {{kind: "text" | "code" | "bold", text: string} | {kind: "link", text: string, href: string}} Token */
const pattern = /\[([^\]\n]+)\]\((https?:\/\/[^\s)]+)\)|`([^`\n]+)`|\*\*([^*\n]+)\*\*|(https?:\/\/[^\s<>()]+[^\s<>().,;:!?'"])/g;
/** * Inline markdown the transcripts actually use: links, bare URLs, `code`, **bold**. * Only http(s) links become tappable. * @param {string} text * @returns {Token[]} */export function inline(text) { /** @type {Token[]} */ const tokens = []; let last = 0; for (const m of text.matchAll(pattern)) { const at = m.index ?? 0; if (at > last) tokens.push({ kind: "text", text: text.slice(last, at) }); if (m[1] && m[2]) tokens.push({ kind: "link", text: m[1], href: m[2] }); else if (m[3]) tokens.push({ kind: "code", text: m[3] }); else if (m[4]) tokens.push({ kind: "bold", text: m[4] }); else if (m[5]) tokens.push({ kind: "link", text: m[5].replace(/^https?:\/\//, ""), href: m[5] }); last = at + m[0].length; } if (last < text.length) tokens.push({ kind: "text", text: text.slice(last) }); return tokens;}