@aglyn/plugins-ai 1.30.0 → 1.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/README.md +2 -1
  2. package/package.json +17 -17
  3. package/src/lib/components/site-chat-api.d.ts +38 -0
  4. package/src/lib/components/site-chat-api.js +65 -0
  5. package/src/lib/components/site-chat-api.js.map +1 -0
  6. package/src/lib/components/site-chat-card.component.d.ts +31 -0
  7. package/src/lib/components/site-chat-card.component.js +474 -0
  8. package/src/lib/components/site-chat-card.component.js.map +1 -0
  9. package/src/lib/components/site-chat-panel.d.ts +38 -0
  10. package/src/lib/components/site-chat-panel.js +749 -0
  11. package/src/lib/components/site-chat-panel.js.map +1 -0
  12. package/src/lib/components/site-chat-runtime.d.ts +29 -0
  13. package/src/lib/components/site-chat-runtime.js +166 -0
  14. package/src/lib/components/site-chat-runtime.js.map +1 -0
  15. package/src/lib/declarations.js +5 -0
  16. package/src/lib/declarations.js.map +1 -1
  17. package/src/lib/model/site-chat.d.ts +219 -0
  18. package/src/lib/model/site-chat.js +200 -0
  19. package/src/lib/model/site-chat.js.map +1 -0
  20. package/src/lib/plugin.js +10 -0
  21. package/src/lib/plugin.js.map +1 -1
  22. package/src/lib/runtime/ai-palette.generated.js +124 -0
  23. package/src/lib/runtime/ai-palette.generated.js.map +1 -1
  24. package/src/lib/server/site-chat-enricher.d.ts +29 -0
  25. package/src/lib/server/site-chat-enricher.js +41 -0
  26. package/src/lib/server/site-chat-enricher.js.map +1 -0
  27. package/src/lib/server/site-chat-owner-routes.d.ts +56 -0
  28. package/src/lib/server/site-chat-owner-routes.js +209 -0
  29. package/src/lib/server/site-chat-owner-routes.js.map +1 -0
  30. package/src/lib/server/site-chat-page-reads.d.ts +23 -0
  31. package/src/lib/server/site-chat-page-reads.js +32 -0
  32. package/src/lib/server/site-chat-page-reads.js.map +1 -0
  33. package/src/lib/server/site-chat-platform.d.ts +25 -0
  34. package/src/lib/server/site-chat-platform.js +405 -0
  35. package/src/lib/server/site-chat-platform.js.map +1 -0
  36. package/src/lib/server/site-chat-prompt.d.ts +83 -0
  37. package/src/lib/server/site-chat-prompt.js +166 -0
  38. package/src/lib/server/site-chat-prompt.js.map +1 -0
  39. package/src/lib/server/site-chat-session.d.ts +33 -0
  40. package/src/lib/server/site-chat-session.js +105 -0
  41. package/src/lib/server/site-chat-session.js.map +1 -0
  42. package/src/lib/server/site-chat-visitor-routes.d.ts +46 -0
  43. package/src/lib/server/site-chat-visitor-routes.js +105 -0
  44. package/src/lib/server/site-chat-visitor-routes.js.map +1 -0
  45. package/src/lib/server/site-chat.d.ts +119 -0
  46. package/src/lib/server/site-chat.js +500 -0
  47. package/src/lib/server/site-chat.js.map +1 -0
  48. package/src/lib/server.js +4 -0
  49. package/src/lib/server.js.map +1 -1
  50. package/src/lib/site-server.d.ts +23 -0
  51. package/src/lib/site-server.js +41 -0
  52. package/src/lib/site-server.js.map +1 -0
  53. package/src/lib/site.d.ts +23 -0
  54. package/src/lib/site.js +33 -0
  55. package/src/lib/site.js.map +1 -0
  56. package/src/lib/usage/site-chat-meter.d.ts +68 -0
  57. package/src/lib/usage/site-chat-meter.js +125 -0
  58. package/src/lib/usage/site-chat-meter.js.map +1 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/components/site-chat-panel.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { SiteChatCard, SiteChatProposal } from '@aglyn/aglyn/plugin-manager/plugin-site-chat-tools'\nimport Box from '@mui/material/Box'\nimport Button from '@mui/material/Button'\nimport Chip from '@mui/material/Chip'\nimport IconButton from '@mui/material/IconButton'\nimport Link from '@mui/material/Link'\nimport Paper from '@mui/material/Paper'\nimport Stack from '@mui/material/Stack'\nimport SvgIcon from '@mui/material/SvgIcon'\nimport TextField from '@mui/material/TextField'\nimport Typography from '@mui/material/Typography'\nimport { Fragment, useCallback, useEffect, useRef, useState, type ReactNode } from 'react'\nimport {\n SITE_CHAT_HISTORY_ROUTE,\n SITE_CHAT_MESSAGE_MAX,\n SITE_CHAT_ROUTE,\n type SiteChatEvent,\n type SiteChatSlice,\n type SiteChatSource,\n type SiteChatTurn,\n} from '../model/site-chat'\n\nconst CLOSE_ICON =\n 'M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z'\nconst SEND_ICON = 'M2,21L23,12L2,3V10L17,12L2,14V21Z'\n\ninterface PanelMessage extends Omit<SiteChatTurn, 'at'> {\n id: string\n handOff?: string\n failed?: boolean\n}\n\nlet counter = 0\nconst nextId = () => `m${(counter += 1)}`\n\n/** A site path, and nothing else, is a link the panel will draw. */\nexport function isSitePath(href: string): boolean {\n return /^\\/(?!\\/)[^\\s]*$/.test(href)\n}\n\n/**\n * Answer text as the visitor sees it: paragraphs, and Markdown links drawn\n * only when they point at a path of this site. Anything else is its text.\n */\nexport function renderSiteChatText(text: string): ReactNode {\n const paragraphs = text.split(/\\n{2,}/)\n return paragraphs.map((paragraph, index) => {\n const parts: ReactNode[] = []\n const pattern = /\\[([^\\]]+)\\]\\(([^)\\s]+)\\)|\\*\\*([^*]+)\\*\\*/g\n let last = 0\n let match: RegExpExecArray | null\n while ((match = pattern.exec(paragraph))) {\n if (match.index > last) parts.push(paragraph.slice(last, match.index))\n if (match[3]) parts.push(<strong key={`b${match.index}`}>{match[3]}</strong>)\n else if (isSitePath(match[2])) {\n parts.push(\n <Link key={`l${match.index}`} href={match[2]} underline=\"always\">\n {match[1]}\n </Link>,\n )\n } else parts.push(match[1])\n last = match.index + match[0].length\n }\n if (last < paragraph.length) parts.push(paragraph.slice(last))\n return (\n <Typography key={index} variant=\"body2\" component=\"p\" sx={{ m: 0, mt: index ? 1 : 0, whiteSpace: 'pre-line' }}>\n {parts.map((part, at) => (\n <Fragment key={at}>{part}</Fragment>\n ))}\n </Typography>\n )\n })\n}\n\n/** The events of one streamed answer, as they arrive. */\nexport async function readSiteChatStream(\n response: Response,\n onEvent: (event: SiteChatEvent) => void,\n): Promise<void> {\n const reader = response.body?.getReader()\n if (!reader) return\n const decoder = new TextDecoder()\n let buffer = ''\n for (;;) {\n const { value, done } = await reader.read()\n if (done) break\n buffer += decoder.decode(value, { stream: true })\n let end: number\n while ((end = buffer.indexOf('\\n\\n')) >= 0) {\n const frame = buffer.slice(0, end)\n buffer = buffer.slice(end + 2)\n const line = frame.split('\\n').find((entry) => entry.startsWith('data: '))\n if (!line) continue\n try {\n onEvent(JSON.parse(line.slice(6)) as SiteChatEvent)\n } catch {\n // A frame that is not an event is skipped.\n }\n }\n }\n}\n\nfunction CardView({ card }: { card: SiteChatCard }) {\n return (\n <Paper\n variant=\"outlined\"\n {...(card.url && isSitePath(card.url) ? { component: 'a' as const, href: card.url } : {})}\n sx={{ display: 'flex', gap: 1.5, p: 1, textDecoration: 'none', color: 'inherit', borderRadius: 2 }}\n >\n {card.imageUrl ? (\n <Box\n component=\"img\"\n src={card.imageUrl}\n alt=\"\"\n loading=\"lazy\"\n sx={{ width: 56, height: 56, objectFit: 'cover', borderRadius: 1.5, flexShrink: 0 }}\n />\n ) : null}\n <Box sx={{ minWidth: 0 }}>\n <Typography variant=\"subtitle2\" noWrap>\n {card.title}\n </Typography>\n {card.price ? (\n <Typography variant=\"body2\">\n {card.price}{' '}\n {card.compareAtPrice ? (\n <Box component=\"s\" sx={{ color: 'text.secondary' }}>\n {card.compareAtPrice}\n </Box>\n ) : null}\n </Typography>\n ) : null}\n {card.caption ? (\n <Typography variant=\"caption\" color=\"text.secondary\">\n {card.caption}\n </Typography>\n ) : null}\n </Box>\n </Paper>\n )\n}\n\ntype ProposalState = 'ready' | 'sending' | 'done' | 'failed'\n\n/** A fresh key for one press, for a door that refuses a repeated attempt. */\nfunction attemptKey(): string {\n try {\n return window.crypto.randomUUID()\n } catch {\n return `${Date.now()}-${Math.random().toString(36).slice(2)}`\n }\n}\n\n/** Where a door's answer may send the visitor: this site, or a checkout it named. */\nfunction nextUrl(answer: { url?: unknown }, fallback?: string): string | null {\n const url = typeof answer.url === 'string' ? answer.url : ''\n if (url && (isSitePath(url) || /^https:\\/\\//.test(url))) return url\n return fallback ?? null\n}\n\nfunction ProposalView({ proposal }: { proposal: SiteChatProposal }) {\n const [state, setState] = useState<ProposalState>('ready')\n const [error, setError] = useState('')\n const [values, setValues] = useState<Record<string, string>>({})\n const fields = proposal.fields ?? []\n const missing = fields.some((field) => field.required && !String(values[field.name] ?? '').trim())\n const confirm = async () => {\n setState('sending')\n setError('')\n try {\n const path = proposal.request.path.replace(/^\\/?api\\//, '')\n // The VISITOR's request, from their browser, with their own cookies:\n // the chat proposed it, and only this press sends it.\n const response = await fetch(`/api/${path}`, {\n method: 'POST',\n credentials: 'same-origin',\n headers: {\n 'Content-Type': 'application/json',\n ...(proposal.idempotent ? { 'Idempotency-Key': attemptKey() } : {}),\n },\n body: JSON.stringify({ ...proposal.request.body, ...values }),\n })\n const answer = (await response.json().catch(() => ({}))) as { error?: string; url?: string }\n if (!response.ok) {\n setState('failed')\n setError(answer.error ?? 'That did not go through. Try again, or use the page.')\n return\n }\n setState('done')\n if (proposal.afterEvent && /^[a-z][a-z0-9:-]{2,60}$/.test(proposal.afterEvent)) {\n window.dispatchEvent(new Event(proposal.afterEvent))\n }\n // A booking or a stay that takes payment answers its checkout: the\n // visitor pays there, as they would from the page.\n const next = nextUrl(answer)\n if (next && proposal.kind !== 'add-to-cart') window.location.assign(next)\n } catch {\n setState('failed')\n setError('That did not go through. Try again, or use the page.')\n }\n }\n return (\n <Paper variant=\"outlined\" sx={{ p: 1.5, borderRadius: 2 }} data-site-chat-proposal={proposal.kind}>\n {proposal.card ? <CardView card={proposal.card} /> : null}\n <Typography variant=\"subtitle2\" sx={{ mt: proposal.card ? 1 : 0 }}>\n {proposal.title}\n </Typography>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {proposal.summary}\n </Typography>\n {state === 'done' ? (\n <Stack direction=\"row\" spacing={1} sx={{ mt: 1, alignItems: 'center' }}>\n <Typography variant=\"body2\" color=\"success.main\">\n Done.\n </Typography>\n {proposal.thenUrl ? (\n <Button size=\"small\" href={proposal.thenUrl}>\n {proposal.kind === 'add-to-cart' ? 'View cart' : 'Continue'}\n </Button>\n ) : null}\n </Stack>\n ) : (\n <Stack spacing={1} sx={{ mt: 1 }}>\n {fields.map((field) => (\n <TextField\n key={field.name}\n size=\"small\"\n type={field.type}\n label={field.label}\n required={field.required}\n value={values[field.name] ?? ''}\n onChange={(event) => setValues((current) => ({ ...current, [field.name]: event.target.value }))}\n />\n ))}\n <Button variant=\"contained\" size=\"small\" disabled={state === 'sending' || missing} onClick={confirm}>\n {proposal.confirmLabel}\n </Button>\n </Stack>\n )}\n {error ? (\n <Typography variant=\"caption\" color=\"error\" component=\"p\" sx={{ mt: 0.5 }}>\n {error}\n </Typography>\n ) : null}\n </Paper>\n )\n}\n\nfunction HandOffForm({ hostId, prompt }: { hostId: string; prompt: string }) {\n const [email, setEmail] = useState('')\n const [question, setQuestion] = useState('')\n const [state, setState] = useState<'ready' | 'sending' | 'sent' | 'failed'>('ready')\n if (state === 'sent') {\n return (\n <Typography variant=\"body2\" color=\"success.main\">\n Thanks. The team will reply by email.\n </Typography>\n )\n }\n const send = async () => {\n setState('sending')\n const response = await fetch(`/api/${SITE_CHAT_ROUTE}/handoff`, {\n method: 'POST',\n credentials: 'same-origin',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ hostId, email, question }),\n }).catch(() => null)\n setState(response?.ok ? 'sent' : 'failed')\n }\n return (\n <Stack spacing={1}>\n <Typography variant=\"body2\">{prompt}</Typography>\n <TextField size=\"small\" type=\"email\" label=\"Your email\" value={email} onChange={(e) => setEmail(e.target.value)} />\n <TextField\n size=\"small\"\n label=\"Your question\"\n multiline\n minRows={2}\n value={question}\n onChange={(e) => setQuestion(e.target.value)}\n />\n <Button\n variant=\"outlined\"\n size=\"small\"\n disabled={state === 'sending' || !/^\\S+@\\S+\\.\\S+$/.test(email) || !question.trim()}\n onClick={send}\n >\n Send to the team\n </Button>\n {state === 'failed' ? (\n <Typography variant=\"caption\" color=\"error\">\n That did not go through. Please try again.\n </Typography>\n ) : null}\n </Stack>\n )\n}\n\nfunction Sources({ sources }: { sources: SiteChatSource[] }) {\n if (!sources.length) return null\n return (\n <Typography variant=\"caption\" color=\"text.secondary\" component=\"p\" sx={{ mt: 0.5 }}>\n From:{' '}\n {sources.map((source, index) => (\n <Fragment key={source.url}>\n {index ? ', ' : ''}\n <Link href={source.url} color=\"inherit\">\n {source.title}\n </Link>\n </Fragment>\n ))}\n </Typography>\n )\n}\n\n/**\n * The chat panel (AGL-4250), loaded on the launcher's press. A conversation\n * is the visitor's own, kept by the site under a signed session cookie, so a\n * visitor who comes back sees where they left off.\n */\nexport function SiteChatPanel({\n hostId,\n slice,\n onClose,\n}: {\n hostId: string\n slice: SiteChatSlice\n onClose: () => void\n}) {\n const [messages, setMessages] = useState<PanelMessage[]>([])\n const [memberName, setMemberName] = useState('')\n const [draft, setDraft] = useState('')\n const [busy, setBusy] = useState(false)\n const listRef = useRef<HTMLDivElement | null>(null)\n\n useEffect(() => {\n let cancelled = false\n fetch(`/api/${SITE_CHAT_HISTORY_ROUTE}?hostId=${encodeURIComponent(hostId)}`, { credentials: 'same-origin' })\n .then((response) => (response.ok ? response.json() : null))\n .then((answer: { turns?: SiteChatTurn[]; member?: { name?: string } | null } | null) => {\n if (cancelled || !answer) return\n if (answer.member?.name) setMemberName(answer.member.name)\n if (Array.isArray(answer.turns)) {\n setMessages(answer.turns.map((turn) => ({ ...turn, id: nextId() })))\n }\n })\n .catch(() => undefined)\n return () => {\n cancelled = true\n }\n }, [hostId])\n\n useEffect(() => {\n listRef.current?.scrollTo({ top: listRef.current.scrollHeight })\n }, [messages])\n\n const ask = useCallback(\n async (question: string) => {\n const message = question.trim().slice(0, SITE_CHAT_MESSAGE_MAX)\n if (!message || busy) return\n setBusy(true)\n setDraft('')\n const answerId = nextId()\n setMessages((list) => [\n ...list,\n { id: nextId(), role: 'visitor', text: message },\n { id: answerId, role: 'assistant', text: '' },\n ])\n const update = (change: (message: PanelMessage) => PanelMessage) =>\n setMessages((list) => list.map((entry) => (entry.id === answerId ? change(entry) : entry)))\n try {\n const response = await fetch(`/api/${SITE_CHAT_ROUTE}`, {\n method: 'POST',\n credentials: 'same-origin',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ hostId, message, path: window.location.pathname }),\n })\n if (!response.ok) {\n const answer = (await response.json().catch(() => ({}))) as { error?: string }\n update((entry) => ({ ...entry, text: answer.error ?? 'The chat is not available right now.', failed: true }))\n return\n }\n await readSiteChatStream(response, (event) => {\n if (event.type === 'delta') update((entry) => ({ ...entry, text: entry.text + event.text }))\n else if (event.type === 'cards') update((entry) => ({ ...entry, cards: event.cards }))\n else if (event.type === 'proposal') update((entry) => ({ ...entry, proposal: event.proposal }))\n else if (event.type === 'handoff') update((entry) => ({ ...entry, handOff: event.message }))\n else if (event.type === 'done') update((entry) => ({ ...entry, sources: event.sources }))\n else if (event.type === 'error') update((entry) => ({ ...entry, text: event.error, failed: true }))\n })\n } catch {\n update((entry) => ({ ...entry, text: 'The chat is not available right now.', failed: true }))\n } finally {\n setBusy(false)\n }\n },\n [busy, hostId],\n )\n\n const greeting = memberName ? `Hi ${memberName}! ${slice.greeting.replace(/^(hi|hello|hey)[!,.]?\\s*/i, '')}` : slice.greeting\n const side = slice.position === 'left' ? { left: { xs: 0, sm: 24 } } : { right: { xs: 0, sm: 24 } }\n return (\n <Paper\n elevation={8}\n role=\"dialog\"\n aria-label=\"Chat\"\n data-site-chat-panel=\"\"\n sx={(theme) => ({\n position: 'fixed',\n zIndex: theme.zIndex.modal,\n bottom: { xs: 0, sm: 24 },\n ...side,\n width: { xs: '100vw', sm: 380 },\n height: { xs: '85dvh', sm: 560 },\n maxHeight: '100dvh',\n display: 'flex',\n flexDirection: 'column',\n borderRadius: { xs: '16px 16px 0 0', sm: 3 },\n overflow: 'hidden',\n })}\n >\n <Stack\n direction=\"row\"\n sx={{ alignItems: 'center', px: 2, py: 1.25, bgcolor: 'primary.main', color: 'primary.contrastText' }}\n >\n <Typography variant=\"subtitle1\" sx={{ flex: 1 }}>\n Chat\n </Typography>\n <IconButton aria-label=\"Close chat\" onClick={onClose} sx={{ color: 'inherit' }}>\n <SvgIcon>\n <path d={CLOSE_ICON} />\n </SvgIcon>\n </IconButton>\n </Stack>\n <Box ref={listRef} sx={{ flex: 1, overflowY: 'auto', p: 2, display: 'flex', flexDirection: 'column', gap: 1.5 }}>\n <Box sx={{ alignSelf: 'flex-start', maxWidth: '88%', bgcolor: 'action.hover', borderRadius: 2, px: 1.5, py: 1 }}>\n <Typography variant=\"body2\">{greeting}</Typography>\n </Box>\n {slice.openingMessage && !messages.length ? (\n <Box sx={{ alignSelf: 'flex-start', maxWidth: '88%', bgcolor: 'action.hover', borderRadius: 2, px: 1.5, py: 1 }}>\n <Typography variant=\"body2\">{slice.openingMessage}</Typography>\n </Box>\n ) : null}\n {messages.map((message) =>\n message.role === 'visitor' ? (\n <Box\n key={message.id}\n sx={{\n alignSelf: 'flex-end',\n maxWidth: '88%',\n bgcolor: 'primary.main',\n color: 'primary.contrastText',\n borderRadius: 2,\n px: 1.5,\n py: 1,\n }}\n >\n <Typography variant=\"body2\">{message.text}</Typography>\n </Box>\n ) : (\n <Stack key={message.id} spacing={1} sx={{ alignSelf: 'flex-start', maxWidth: '92%' }}>\n <Box\n aria-live=\"polite\"\n sx={{ bgcolor: 'action.hover', borderRadius: 2, px: 1.5, py: 1, color: message.failed ? 'error.main' : undefined }}\n >\n {message.text ? renderSiteChatText(message.text) : <Typography variant=\"body2\">…</Typography>}\n <Sources sources={message.sources ?? []} />\n </Box>\n {(message.cards ?? []).map((card) => (\n <CardView key={card.url ?? card.title} card={card} />\n ))}\n {message.proposal ? <ProposalView proposal={message.proposal} /> : null}\n {message.handOff && slice.handOff ? <HandOffForm hostId={hostId} prompt={message.handOff} /> : null}\n </Stack>\n ),\n )}\n {!messages.length && slice.chips.length ? (\n <Stack direction=\"row\" sx={{ flexWrap: 'wrap', gap: 1 }}>\n {slice.chips.map((chip) => (\n <Chip key={chip} label={chip} variant=\"outlined\" onClick={() => ask(chip)} />\n ))}\n </Stack>\n ) : null}\n </Box>\n <Box\n component=\"form\"\n onSubmit={(event) => {\n event.preventDefault()\n void ask(draft)\n }}\n sx={{ display: 'flex', gap: 1, p: 1.5, borderTop: 1, borderColor: 'divider' }}\n >\n <TextField\n size=\"small\"\n fullWidth\n placeholder=\"Ask a question\"\n value={draft}\n onChange={(event) => setDraft(event.target.value)}\n slotProps={{ htmlInput: { maxLength: SITE_CHAT_MESSAGE_MAX, 'aria-label': 'Your question' } }}\n />\n <IconButton type=\"submit\" color=\"primary\" aria-label=\"Send\" disabled={busy || !draft.trim()}>\n <SvgIcon>\n <path d={SEND_ICON} />\n </SvgIcon>\n </IconButton>\n </Box>\n <Typography variant=\"caption\" color=\"text.secondary\" sx={{ px: 2, pb: 1 }}>\n Answers are written by AI from this site's own pages.\n </Typography>\n </Paper>\n )\n}\n\nexport default SiteChatPanel\n"],"names":["Box","Button","Chip","IconButton","Link","Paper","Stack","SvgIcon","TextField","Typography","Fragment","useCallback","useEffect","useRef","useState","SITE_CHAT_HISTORY_ROUTE","SITE_CHAT_MESSAGE_MAX","SITE_CHAT_ROUTE","CLOSE_ICON","SEND_ICON","counter","nextId","isSitePath","href","test","renderSiteChatText","text","paragraphs","split","map","paragraph","index","parts","pattern","last","match","exec","push","slice","strong","underline","length","variant","component","sx","m","mt","whiteSpace","part","at","readSiteChatStream","response","onEvent","reader","body","getReader","decoder","TextDecoder","buffer","value","done","read","decode","stream","end","indexOf","frame","line","find","entry","startsWith","JSON","parse","CardView","card","url","display","gap","p","textDecoration","color","borderRadius","imageUrl","src","alt","loading","width","height","objectFit","flexShrink","minWidth","noWrap","title","price","compareAtPrice","caption","attemptKey","window","crypto","randomUUID","Date","now","Math","random","toString","nextUrl","answer","fallback","ProposalView","proposal","state","setState","error","setError","values","setValues","fields","missing","some","field","required","String","name","trim","confirm","path","request","replace","fetch","method","credentials","headers","idempotent","stringify","json","catch","ok","afterEvent","dispatchEvent","Event","next","kind","location","assign","data-site-chat-proposal","summary","direction","spacing","alignItems","thenUrl","size","type","label","onChange","event","current","target","disabled","onClick","confirmLabel","HandOffForm","hostId","prompt","email","setEmail","question","setQuestion","send","e","multiline","minRows","Sources","sources","source","SiteChatPanel","onClose","messages","setMessages","memberName","setMemberName","draft","setDraft","busy","setBusy","listRef","cancelled","encodeURIComponent","then","member","Array","isArray","turns","turn","id","undefined","scrollTo","top","scrollHeight","ask","message","answerId","list","role","update","change","pathname","failed","cards","handOff","greeting","side","position","left","xs","sm","right","elevation","aria-label","data-site-chat-panel","theme","zIndex","modal","bottom","maxHeight","flexDirection","overflow","px","py","bgcolor","flex","d","ref","overflowY","alignSelf","maxWidth","openingMessage","aria-live","chips","flexWrap","chip","onSubmit","preventDefault","borderTop","borderColor","fullWidth","placeholder","slotProps","htmlInput","maxLength","pb"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC;;AAGD,OAAOA,SAAS,oBAAmB;AACnC,OAAOC,YAAY,uBAAsB;AACzC,OAAOC,UAAU,qBAAoB;AACrC,OAAOC,gBAAgB,2BAA0B;AACjD,OAAOC,UAAU,qBAAoB;AACrC,OAAOC,WAAW,sBAAqB;AACvC,OAAOC,WAAW,sBAAqB;AACvC,OAAOC,aAAa,wBAAuB;AAC3C,OAAOC,eAAe,0BAAyB;A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ASvE,OAAM;wBAAUyI,cAAW;wBAAO5D,UAAUyB,QAAQ,CAACF,MAAMzD,IAAI;kCACvF,cAAA,KAACpH;sCACC,cAAA,KAACsH;gCAAKyG,GAAGnN;;;;;;0BAIf,KAACV;gBAAWiC,SAAQ;gBAAUsC,OAAM;gBAAiBpC,IAAI;oBAAEsL,IAAI;oBAAGuB,IAAI;gBAAE;0BAAG;;;;AAKjF;AAEA,eAAe3E,cAAa"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import type { SiteRuntimeProps } from '@aglyn/aglyn/plugin-manager/site-runtime';
18
+ /**
19
+ * The site chat's launcher (AGL-4250). Nothing at first render: the button
20
+ * waits for the page to load and go idle, so it costs the page neither its
21
+ * first paint nor its interactivity, and the panel's code loads only when a
22
+ * visitor opens it. Same origin, no third-party script.
23
+ *
24
+ * The owner's opening message, where there is one, rises beside the button
25
+ * once per visitor a few seconds after the page settles; dismissing it or
26
+ * opening the chat retires it on this browser.
27
+ */
28
+ export declare function SiteChatRuntime({ hostId, page }: SiteRuntimeProps): import("react").JSX.Element;
29
+ export default SiteChatRuntime;
@@ -0,0 +1,166 @@
1
+ import { _ as _extends } from "@swc/helpers/_/_extends";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ /**
4
+ * @license
5
+ * Copyright 2026 Aglyn LLC
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */ import { usePageIdle } from "@aglyn/aglyn/app-utils/page-idle";
19
+ import Box from "@mui/material/Box";
20
+ import ButtonBase from "@mui/material/ButtonBase";
21
+ import Fab from "@mui/material/Fab";
22
+ import IconButton from "@mui/material/IconButton";
23
+ import Paper from "@mui/material/Paper";
24
+ import SvgIcon from "@mui/material/SvgIcon";
25
+ import Typography from "@mui/material/Typography";
26
+ import { lazy, Suspense, useCallback, useEffect, useState } from "react";
27
+ import { readSiteChatSlice, SITE_CHAT_PAGE_PROP } from "../model/site-chat.js";
28
+ const SiteChatPanel = /*#__PURE__*/ lazy(()=>import("./site-chat-panel.js"));
29
+ /** Material Design Icons `message-text` and `close` (Apache-2.0), inline. */ const CHAT_ICON = 'M20,2H4A2,2 0 0,0 2,4V22L6,18H20A2,2 0 0,0 22,16V4A2,2 0 0,0 20,2M6,9H18V11H6M14,14H6V12H14M18,8H6V6H18';
30
+ const CLOSE_ICON = 'M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z';
31
+ const OPENING_SEEN_KEY = 'aglyn:site-chat:opening:';
32
+ const OPENING_DELAY_MS = 4000;
33
+ function readMark(key) {
34
+ try {
35
+ return window.localStorage.getItem(key) === '1';
36
+ } catch (unused) {
37
+ return false;
38
+ }
39
+ }
40
+ function writeMark(key) {
41
+ try {
42
+ window.localStorage.setItem(key, '1');
43
+ } catch (unused) {
44
+ // A browser that cannot store shows the opening message once per page.
45
+ }
46
+ }
47
+ /**
48
+ * The site chat's launcher (AGL-4250). Nothing at first render: the button
49
+ * waits for the page to load and go idle, so it costs the page neither its
50
+ * first paint nor its interactivity, and the panel's code loads only when a
51
+ * visitor opens it. Same origin, no third-party script.
52
+ *
53
+ * The owner's opening message, where there is one, rises beside the button
54
+ * once per visitor a few seconds after the page settles; dismissing it or
55
+ * opening the chat retires it on this browser.
56
+ */ export function SiteChatRuntime({ hostId, page }) {
57
+ const slice = readSiteChatSlice(page == null ? void 0 : page[SITE_CHAT_PAGE_PROP]);
58
+ const idle = usePageIdle();
59
+ const [open, setOpen] = useState(false);
60
+ const [opening, setOpening] = useState(false);
61
+ const openingKey = `${OPENING_SEEN_KEY}${hostId != null ? hostId : ''}`;
62
+ useEffect(()=>{
63
+ if (!(slice == null ? void 0 : slice.openingMessage) || !idle || open || readMark(openingKey)) return undefined;
64
+ const timer = window.setTimeout(()=>setOpening(true), OPENING_DELAY_MS);
65
+ return ()=>window.clearTimeout(timer);
66
+ }, [
67
+ slice == null ? void 0 : slice.openingMessage,
68
+ idle,
69
+ open,
70
+ openingKey
71
+ ]);
72
+ const retireOpening = useCallback(()=>{
73
+ setOpening(false);
74
+ writeMark(openingKey);
75
+ }, [
76
+ openingKey
77
+ ]);
78
+ const launch = useCallback(()=>{
79
+ retireOpening();
80
+ setOpen(true);
81
+ }, [
82
+ retireOpening
83
+ ]);
84
+ if (!slice || !idle || !hostId) return null;
85
+ const side = slice.position === 'left' ? {
86
+ left: 24
87
+ } : {
88
+ right: 24
89
+ };
90
+ return /*#__PURE__*/ _jsxs(_Fragment, {
91
+ children: [
92
+ opening && !open ? /*#__PURE__*/ _jsxs(Paper, {
93
+ elevation: 6,
94
+ role: "status",
95
+ "data-site-chat-opening": "",
96
+ sx: (theme)=>_extends({
97
+ position: 'fixed',
98
+ zIndex: theme.zIndex.fab,
99
+ bottom: 96
100
+ }, side, {
101
+ maxWidth: 'min(320px, calc(100vw - 48px))',
102
+ borderRadius: 3,
103
+ display: 'flex',
104
+ alignItems: 'flex-start'
105
+ }),
106
+ children: [
107
+ /*#__PURE__*/ _jsx(ButtonBase, {
108
+ onClick: launch,
109
+ sx: {
110
+ textAlign: 'left',
111
+ p: 2,
112
+ borderRadius: 3,
113
+ flex: 1
114
+ },
115
+ children: /*#__PURE__*/ _jsx(Typography, {
116
+ variant: "body2",
117
+ children: slice.openingMessage
118
+ })
119
+ }),
120
+ /*#__PURE__*/ _jsx(IconButton, {
121
+ size: "small",
122
+ "aria-label": "Dismiss",
123
+ onClick: retireOpening,
124
+ sx: {
125
+ m: 0.5
126
+ },
127
+ children: /*#__PURE__*/ _jsx(SvgIcon, {
128
+ fontSize: "small",
129
+ children: /*#__PURE__*/ _jsx("path", {
130
+ d: CLOSE_ICON
131
+ })
132
+ })
133
+ })
134
+ ]
135
+ }) : null,
136
+ open ? /*#__PURE__*/ _jsx(Suspense, {
137
+ fallback: null,
138
+ children: /*#__PURE__*/ _jsx(SiteChatPanel, {
139
+ hostId: hostId,
140
+ slice: slice,
141
+ onClose: ()=>setOpen(false)
142
+ })
143
+ }) : /*#__PURE__*/ _jsx(Box, {
144
+ sx: (theme)=>_extends({
145
+ position: 'fixed',
146
+ zIndex: theme.zIndex.fab,
147
+ bottom: 24
148
+ }, side),
149
+ children: /*#__PURE__*/ _jsx(Fab, {
150
+ color: "primary",
151
+ "aria-label": "Chat with us",
152
+ onClick: launch,
153
+ "data-site-chat-launcher": "",
154
+ children: /*#__PURE__*/ _jsx(SvgIcon, {
155
+ children: /*#__PURE__*/ _jsx("path", {
156
+ d: CHAT_ICON
157
+ })
158
+ })
159
+ })
160
+ })
161
+ ]
162
+ });
163
+ }
164
+ export default SiteChatRuntime;
165
+
166
+ //# sourceMappingURL=site-chat-runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/components/site-chat-runtime.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { usePageIdle } from '@aglyn/aglyn/app-utils/page-idle'\nimport type { SiteRuntimeProps } from '@aglyn/aglyn/plugin-manager/site-runtime'\nimport Box from '@mui/material/Box'\nimport ButtonBase from '@mui/material/ButtonBase'\nimport Fab from '@mui/material/Fab'\nimport IconButton from '@mui/material/IconButton'\nimport Paper from '@mui/material/Paper'\nimport SvgIcon from '@mui/material/SvgIcon'\nimport Typography from '@mui/material/Typography'\nimport { lazy, Suspense, useCallback, useEffect, useState } from 'react'\nimport { readSiteChatSlice, SITE_CHAT_PAGE_PROP } from '../model/site-chat'\n\nconst SiteChatPanel = lazy(() => import('./site-chat-panel'))\n\n/** Material Design Icons `message-text` and `close` (Apache-2.0), inline. */\nconst CHAT_ICON =\n 'M20,2H4A2,2 0 0,0 2,4V22L6,18H20A2,2 0 0,0 22,16V4A2,2 0 0,0 20,2M6,9H18V11H6M14,14H6V12H14M18,8H6V6H18'\nconst CLOSE_ICON =\n 'M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z'\n\nconst OPENING_SEEN_KEY = 'aglyn:site-chat:opening:'\nconst OPENING_DELAY_MS = 4_000\n\nfunction readMark(key: string): boolean {\n try {\n return window.localStorage.getItem(key) === '1'\n } catch {\n return false\n }\n}\n\nfunction writeMark(key: string): void {\n try {\n window.localStorage.setItem(key, '1')\n } catch {\n // A browser that cannot store shows the opening message once per page.\n }\n}\n\n/**\n * The site chat's launcher (AGL-4250). Nothing at first render: the button\n * waits for the page to load and go idle, so it costs the page neither its\n * first paint nor its interactivity, and the panel's code loads only when a\n * visitor opens it. Same origin, no third-party script.\n *\n * The owner's opening message, where there is one, rises beside the button\n * once per visitor a few seconds after the page settles; dismissing it or\n * opening the chat retires it on this browser.\n */\nexport function SiteChatRuntime({ hostId, page }: SiteRuntimeProps) {\n const slice = readSiteChatSlice(page?.[SITE_CHAT_PAGE_PROP])\n const idle = usePageIdle()\n const [open, setOpen] = useState(false)\n const [opening, setOpening] = useState(false)\n const openingKey = `${OPENING_SEEN_KEY}${hostId ?? ''}`\n\n useEffect(() => {\n if (!slice?.openingMessage || !idle || open || readMark(openingKey)) return undefined\n const timer = window.setTimeout(() => setOpening(true), OPENING_DELAY_MS)\n return () => window.clearTimeout(timer)\n }, [slice?.openingMessage, idle, open, openingKey])\n\n const retireOpening = useCallback(() => {\n setOpening(false)\n writeMark(openingKey)\n }, [openingKey])\n\n const launch = useCallback(() => {\n retireOpening()\n setOpen(true)\n }, [retireOpening])\n\n if (!slice || !idle || !hostId) return null\n const side = slice.position === 'left' ? { left: 24 } : { right: 24 }\n return (\n <>\n {opening && !open ? (\n <Paper\n elevation={6}\n role=\"status\"\n data-site-chat-opening=\"\"\n sx={(theme) => ({\n position: 'fixed',\n zIndex: theme.zIndex.fab,\n bottom: 96,\n ...side,\n maxWidth: 'min(320px, calc(100vw - 48px))',\n borderRadius: 3,\n display: 'flex',\n alignItems: 'flex-start',\n })}\n >\n <ButtonBase onClick={launch} sx={{ textAlign: 'left', p: 2, borderRadius: 3, flex: 1 }}>\n <Typography variant=\"body2\">{slice.openingMessage}</Typography>\n </ButtonBase>\n <IconButton size=\"small\" aria-label=\"Dismiss\" onClick={retireOpening} sx={{ m: 0.5 }}>\n <SvgIcon fontSize=\"small\">\n <path d={CLOSE_ICON} />\n </SvgIcon>\n </IconButton>\n </Paper>\n ) : null}\n {open ? (\n <Suspense fallback={null}>\n <SiteChatPanel hostId={hostId} slice={slice} onClose={() => setOpen(false)} />\n </Suspense>\n ) : (\n <Box sx={(theme) => ({ position: 'fixed', zIndex: theme.zIndex.fab, bottom: 24, ...side })}>\n <Fab color=\"primary\" aria-label=\"Chat with us\" onClick={launch} data-site-chat-launcher=\"\">\n <SvgIcon>\n <path d={CHAT_ICON} />\n </SvgIcon>\n </Fab>\n </Box>\n )}\n </>\n )\n}\n\nexport default SiteChatRuntime\n"],"names":["usePageIdle","Box","ButtonBase","Fab","IconButton","Paper","SvgIcon","Typography","lazy","Suspense","useCallback","useEffect","useState","readSiteChatSlice","SITE_CHAT_PAGE_PROP","SiteChatPanel","CHAT_ICON","CLOSE_ICON","OPENING_SEEN_KEY","OPENING_DELAY_MS","readMark","key","window","localStorage","getItem","writeMark","setItem","SiteChatRuntime","hostId","page","slice","idle","open","setOpen","opening","setOpening","openingKey","openingMessage","undefined","timer","setTimeout","clearTimeout","retireOpening","launch","side","position","left","right","elevation","role","data-site-chat-opening","sx","theme","zIndex","fab","bottom","maxWidth","borderRadius","display","alignItems","onClick","textAlign","p","flex","variant","size","aria-label","m","fontSize","path","d","fallback","onClose","color","data-site-chat-launcher"],"mappings":";;AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,WAAW,QAAQ,mCAAkC;AAE9D,OAAOC,SAAS,oBAAmB;AACnC,OAAOC,gBAAgB,2BAA0B;AACjD,OAAOC,SAAS,oBAAmB;AACnC,OAAOC,gBAAgB,2BAA0B;AACjD,OAAOC,WAAW,sBAAqB;AACvC,OAAOC,aAAa,wBAAuB;AAC3C,OAAOC,gBAAgB,2BAA0B;AACjD,SAASC,IAAI,EAAEC,QAAQ,EAAEC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AACxE,SAASC,iBAAiB,EAAEC,mBAAmB,QAAQ,wBAAoB;AAE3E,MAAMC,8BAAgBP,KAAK,IAAM,MAAM,CAAC;AAExC,2EAA2E,GAC3E,MAAMQ,YACJ;AACF,MAAMC,aACJ;AAEF,MAAMC,mBAAmB;AACzB,MAAMC,mBAAmB;AAEzB,SAASC,SAASC,GAAW;IAC3B,IAAI;QACF,OAAOC,OAAOC,YAAY,CAACC,OAAO,CAAC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AAG;wBACxBC,QAAQ;uBACLX;wBACHY,UAAU;wBACVC,cAAc;wBACdC,SAAS;wBACTC,YAAY;;;kCAGd,KAACzD;wBAAW0D,SAASjB;wBAAQQ,IAAI;4BAAEU,WAAW;4BAAQC,GAAG;4BAAGL,cAAc;4BAAGM,MAAM;wBAAE;kCACnF,cAAA,KAACxD;4BAAWyD,SAAQ;sCAASlC,MAAMO,cAAc;;;kCAEnD,KAACjC;wBAAW6D,MAAK;wBAAQC,cAAW;wBAAUN,SAASlB;wBAAeS,IAAI;4BAAEgB,GAAG;wBAAI;kCACjF,cAAA,KAAC7D;4BAAQ8D,UAAS;sCAChB,cAAA,KAACC;gCAAKC,GAAGrD;;;;;iBAIb;YACHe,qBACC,KAACvB;gBAAS8D,UAAU;0BAClB,cAAA,KAACxD;oBAAca,QAAQA;oBAAQE,OAAOA;oBAAO0C,SAAS,IAAMvC,QAAQ;;+BAGtE,KAAChC;gBAAIkD,IAAI,CAACC,QAAW;wBAAEP,UAAU;wBAASQ,QAAQD,MAAMC,MAAM,CAACC,GAAG;wBAAEC,QAAQ;uBAAOX;0BACjF,cAAA,KAACzC;oBAAIsE,OAAM;oBAAUP,cAAW;oBAAeN,SAASjB;oBAAQ+B,2BAAwB;8BACtF,cAAA,KAACpE;kCACC,cAAA,KAAC+D;4BAAKC,GAAGtD;;;;;;;AAOvB;AAEA,eAAeW,gBAAe"}
@@ -87,10 +87,15 @@ import { registerAiActivityActions } from "./activity/ai-activity-actions.js";
87
87
  },
88
88
  // Gated even while the route 501s without a provider key — the switch
89
89
  // predates the key on purpose.
90
+ // The AI chat on a published site (AGL-4250) is the same assistant,
91
+ // answering visitors: the switch stops it with the console's.
90
92
  apiPaths: {
91
93
  exact: [
92
94
  'ai/assist',
93
95
  'assist/chat'
96
+ ],
97
+ prefixes: [
98
+ 'ai/site-chat'
94
99
  ]
95
100
  }
96
101
  },
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../libs/plugins/ai/src/lib/declarations.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// Named modules rather than the `@aglyn/aglyn` barrel: both apps load this\n// on the server at boot, and the full barrel carries client-only contexts\n// (AGL-405).\nimport {\n aiCreditsQuotaPerUnit,\n planSellsAiCredits,\n} from '@aglyn/aglyn/app-utils/plan-entitlements'\nimport { AI_CREDIT_BLOCKS_MAX } from '@aglyn/aglyn/app-utils/ai-credit-blocks'\nimport { registerPluginConfigSchema } from '@aglyn/aglyn/plugin-manager/plugin-config'\nimport {\n registerPluginEntitlements,\n type PluginEntitlementRegistration,\n} from '@aglyn/aglyn/plugin-manager/plugin-entitlements'\nimport { AI_PLUGIN_ID } from './constants'\nimport { AI_ORG_PERMISSIONS, AI_WORKSPACE_PERMISSIONS } from './model/ai-permissions'\nimport { AI_CONFIG_SCHEMA } from './plugin-config'\nimport { registerAiActivityActions } from './activity/ai-activity-actions'\n\n/**\n * The plugin's DECLARATIONS (AGL-2939): what core must know about this\n * plugin before any of its surfaces load — its billing and access keys,\n * the AI permission keys it adds to the org catalog (AGL-2984), its\n * activity codes, its settings schema. Loaded eagerly by both apps\n * through the generated declarations manifest, at boot on the server and\n * with the plugin loader on the client, so a core billing route folds the\n * add-on and the staff lockdown page lists the levers whether or not a\n * request has touched the plugin yet. Light by construction: nothing here\n * reaches a provider, Firestore or React.\n *\n * The plan tables keep the per-plan defaults for `aiGenerative` and\n * `aiAssist`, and `ai-credit-blocks.ts` keeps the credit block's price and\n * credits, so this names keys and restates no figure.\n *\n * `ai-assist` and `ai-generate` are separate levers because the two doors\n * spend at different rates and an incident on one need not stop the other\n * (AGL-2903). Both grant the staff bypass: a provider incident is verified\n * recovered by staff making one real call, not by lifting the lock and\n * watching customers find out.\n */\nexport const AI_PLUGIN_ENTITLEMENTS: PluginEntitlementRegistration = {\n pluginId: AI_PLUGIN_ID,\n seatAddons: [\n {\n key: 'aiAddon',\n label: 'AI add-on',\n // Credits by the block (AGL-4144): 0 to 30 blocks, each adding 5,000\n // credits to the plan's included band — one pool, widened by what was\n // bought rather than by which plan bought it.\n maxUnits: AI_CREDIT_BLOCKS_MAX,\n quota: {\n key: 'assistCreditsPerMonth',\n perUnit: aiCreditsQuotaPerUnit,\n },\n features: ['aiGenerative', 'aiAssist'],\n soldOn: planSellsAiCredits,\n },\n ],\n features: [\n { key: 'aiAssist', label: 'AI assist' },\n { key: 'aiGenerative', label: 'AI generation' },\n ],\n lockdownFeatures: [\n {\n key: 'ai-assist',\n label: 'AI assist',\n customerName: 'AI assist',\n staffBypass: true,\n notice: {\n title: 'AI assist is temporarily unavailable',\n body: 'AI assist is temporarily unavailable. Your content is unaffected — please try again shortly.',\n },\n // Gated even while the route 501s without a provider key — the switch\n // predates the key on purpose.\n apiPaths: { exact: ['ai/assist', 'assist/chat'] },\n },\n {\n key: 'ai-generate',\n label: 'AI generation',\n customerName: 'AI generation',\n staffBypass: true,\n notice: {\n title: 'AI generation is temporarily unavailable',\n body: 'Generating sections, pages and automations with AI is temporarily unavailable. Everything already built is unaffected — please try again shortly.',\n },\n // `ai/seo` (AGL-2910) applies a finished audit's drafts; it spends\n // nothing, and it is still a generative door the switch stops.\n apiPaths: { prefixes: ['ai/generate', 'ai/jobs', 'ai/seo'] },\n },\n ],\n orgPermissions: [...AI_ORG_PERMISSIONS, ...AI_WORKSPACE_PERMISSIONS],\n}\n\nlet declared = false\n\n/**\n * Registers everything above, and the activity codes. Idempotent: the\n * declarations manifest runs it once per process, and a surface's register\n * fn may call it again. The codes are a call rather than an import made\n * for what the module does as it loads, because the browser's manifest\n * reaches that module through nothing else, and a bundler honoring this\n * package's `sideEffects` deletes such an import (AGL-3025).\n */\nexport function registerAiDeclarations(): void {\n if (declared) return\n declared = true\n registerPluginEntitlements(AI_PLUGIN_ENTITLEMENTS)\n registerPluginConfigSchema(AI_CONFIG_SCHEMA)\n registerAiActivityActions()\n}\n\nregisterAiDeclarations()\n"],"names":["aiCreditsQuotaPerUnit","planSellsAiCredits","AI_CREDIT_BLOCKS_MAX","registerPluginConfigSchema","registerPluginEntitlements","AI_PLUGIN_ID","AI_ORG_PERMISSIONS","AI_WORKSPACE_PERMISSIONS","AI_CONFIG_SCHEMA","registerAiActivityActions","AI_PLUGIN_ENTITLEMENTS","pluginId","seatAddons","key","label","maxUnits","quota","perUnit","features","soldOn","lockdownFeatures","customerName","staffBypass","notice","title","body","apiPaths","exact","prefixes","orgPermissions","declared","registerAiDeclarations"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,2EAA2E;AAC3E,0EAA0E;AAC1E,aAAa;AACb,SACEA,qBAAqB,EACrBC,kBAAkB,QACb,2CAA0C;AACjD,SAASC,oBAAoB,QAAQ,0CAAyC;AAC9E,SAASC,0BAA0B,QAAQ,4CAA2C;AACtF,SACEC,0BAA0B,QAErB,kDAAiD;AACxD,SAASC,YAAY,QAAQ,iBAAa;AAC1C,SAASC,kBAAkB,EAAEC,wBAAwB,QAAQ,4BAAwB;AACrF,SAASC,gBAAgB,QAAQ,qBAAiB;AAClD,SAASC,yBAAyB,QAAQ,oCAAgC;AAE1E;;;;;;;;;;;;;;;;;;;;CAoBC,GACD,OAAO,MAAMC,yBAAwD;IACnEC,UAAUN;IACVO,YAAY;QACV;YACEC,KAAK;YACLC,OAAO;YACP,qEAAqE;YACrE,sEAAsE;YACtE,8CAA8C;YAC9CC,UAAUb;YACVc,OAAO;gBACLH,KAAK;gBACLI,SAASjB;YACX;YACAkB,UAAU;gBAAC;gBAAgB;aAAW;YACtCC,QAAQlB;QACV;KACD;IACDiB,UAAU;QACR;YAAEL,KAAK;YAAYC,OAAO;QAAY;QACtC;YAAED,KAAK;YAAgBC,OAAO;QAAgB;KAC/C;IACDM,kBAAkB;QAChB;YACEP,KAAK;YACLC,OAAO;YACPO,cAAc;YACdC,aAAa;YACbC,QAAQ;gBACNC,OAAO;gBACPC,MAAM;YACR;YACA,sEAAsE;YACtE,+BAA+B;YAC/BC,UAAU;gBAAEC,OAAO;oBAAC;oBAAa;iBAAc;YAAC;QAClD;QACA;YACEd,KAAK;YACLC,OAAO;YACPO,cAAc;YACdC,aAAa;YACbC,QAAQ;gBACNC,OAAO;gBACPC,MAAM;YACR;YACA,mEAAmE;YACnE,+DAA+D;YAC/DC,UAAU;gBAAEE,UAAU;oBAAC;oBAAe;oBAAW;iBAAS;YAAC;QAC7D;KACD;IACDC,gBAAgB;WAAIvB;WAAuBC;KAAyB;AACtE,EAAC;AAED,IAAIuB,WAAW;AAEf;;;;;;;CAOC,GACD,OAAO,SAASC;IACd,IAAID,UAAU;IACdA,WAAW;IACX1B,2BAA2BM;IAC3BP,2BAA2BK;IAC3BC;AACF;AAEAsB"}
1
+ {"version":3,"sources":["../../../../../../libs/plugins/ai/src/lib/declarations.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// Named modules rather than the `@aglyn/aglyn` barrel: both apps load this\n// on the server at boot, and the full barrel carries client-only contexts\n// (AGL-405).\nimport {\n aiCreditsQuotaPerUnit,\n planSellsAiCredits,\n} from '@aglyn/aglyn/app-utils/plan-entitlements'\nimport { AI_CREDIT_BLOCKS_MAX } from '@aglyn/aglyn/app-utils/ai-credit-blocks'\nimport { registerPluginConfigSchema } from '@aglyn/aglyn/plugin-manager/plugin-config'\nimport {\n registerPluginEntitlements,\n type PluginEntitlementRegistration,\n} from '@aglyn/aglyn/plugin-manager/plugin-entitlements'\nimport { AI_PLUGIN_ID } from './constants'\nimport { AI_ORG_PERMISSIONS, AI_WORKSPACE_PERMISSIONS } from './model/ai-permissions'\nimport { AI_CONFIG_SCHEMA } from './plugin-config'\nimport { registerAiActivityActions } from './activity/ai-activity-actions'\n\n/**\n * The plugin's DECLARATIONS (AGL-2939): what core must know about this\n * plugin before any of its surfaces load — its billing and access keys,\n * the AI permission keys it adds to the org catalog (AGL-2984), its\n * activity codes, its settings schema. Loaded eagerly by both apps\n * through the generated declarations manifest, at boot on the server and\n * with the plugin loader on the client, so a core billing route folds the\n * add-on and the staff lockdown page lists the levers whether or not a\n * request has touched the plugin yet. Light by construction: nothing here\n * reaches a provider, Firestore or React.\n *\n * The plan tables keep the per-plan defaults for `aiGenerative` and\n * `aiAssist`, and `ai-credit-blocks.ts` keeps the credit block's price and\n * credits, so this names keys and restates no figure.\n *\n * `ai-assist` and `ai-generate` are separate levers because the two doors\n * spend at different rates and an incident on one need not stop the other\n * (AGL-2903). Both grant the staff bypass: a provider incident is verified\n * recovered by staff making one real call, not by lifting the lock and\n * watching customers find out.\n */\nexport const AI_PLUGIN_ENTITLEMENTS: PluginEntitlementRegistration = {\n pluginId: AI_PLUGIN_ID,\n seatAddons: [\n {\n key: 'aiAddon',\n label: 'AI add-on',\n // Credits by the block (AGL-4144): 0 to 30 blocks, each adding 5,000\n // credits to the plan's included band — one pool, widened by what was\n // bought rather than by which plan bought it.\n maxUnits: AI_CREDIT_BLOCKS_MAX,\n quota: {\n key: 'assistCreditsPerMonth',\n perUnit: aiCreditsQuotaPerUnit,\n },\n features: ['aiGenerative', 'aiAssist'],\n soldOn: planSellsAiCredits,\n },\n ],\n features: [\n { key: 'aiAssist', label: 'AI assist' },\n { key: 'aiGenerative', label: 'AI generation' },\n ],\n lockdownFeatures: [\n {\n key: 'ai-assist',\n label: 'AI assist',\n customerName: 'AI assist',\n staffBypass: true,\n notice: {\n title: 'AI assist is temporarily unavailable',\n body: 'AI assist is temporarily unavailable. Your content is unaffected — please try again shortly.',\n },\n // Gated even while the route 501s without a provider key — the switch\n // predates the key on purpose.\n // The AI chat on a published site (AGL-4250) is the same assistant,\n // answering visitors: the switch stops it with the console's.\n apiPaths: { exact: ['ai/assist', 'assist/chat'], prefixes: ['ai/site-chat'] },\n },\n {\n key: 'ai-generate',\n label: 'AI generation',\n customerName: 'AI generation',\n staffBypass: true,\n notice: {\n title: 'AI generation is temporarily unavailable',\n body: 'Generating sections, pages and automations with AI is temporarily unavailable. Everything already built is unaffected — please try again shortly.',\n },\n // `ai/seo` (AGL-2910) applies a finished audit's drafts; it spends\n // nothing, and it is still a generative door the switch stops.\n apiPaths: { prefixes: ['ai/generate', 'ai/jobs', 'ai/seo'] },\n },\n ],\n orgPermissions: [...AI_ORG_PERMISSIONS, ...AI_WORKSPACE_PERMISSIONS],\n}\n\nlet declared = false\n\n/**\n * Registers everything above, and the activity codes. Idempotent: the\n * declarations manifest runs it once per process, and a surface's register\n * fn may call it again. The codes are a call rather than an import made\n * for what the module does as it loads, because the browser's manifest\n * reaches that module through nothing else, and a bundler honoring this\n * package's `sideEffects` deletes such an import (AGL-3025).\n */\nexport function registerAiDeclarations(): void {\n if (declared) return\n declared = true\n registerPluginEntitlements(AI_PLUGIN_ENTITLEMENTS)\n registerPluginConfigSchema(AI_CONFIG_SCHEMA)\n registerAiActivityActions()\n}\n\nregisterAiDeclarations()\n"],"names":["aiCreditsQuotaPerUnit","planSellsAiCredits","AI_CREDIT_BLOCKS_MAX","registerPluginConfigSchema","registerPluginEntitlements","AI_PLUGIN_ID","AI_ORG_PERMISSIONS","AI_WORKSPACE_PERMISSIONS","AI_CONFIG_SCHEMA","registerAiActivityActions","AI_PLUGIN_ENTITLEMENTS","pluginId","seatAddons","key","label","maxUnits","quota","perUnit","features","soldOn","lockdownFeatures","customerName","staffBypass","notice","title","body","apiPaths","exact","prefixes","orgPermissions","declared","registerAiDeclarations"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,2EAA2E;AAC3E,0EAA0E;AAC1E,aAAa;AACb,SACEA,qBAAqB,EACrBC,kBAAkB,QACb,2CAA0C;AACjD,SAASC,oBAAoB,QAAQ,0CAAyC;AAC9E,SAASC,0BAA0B,QAAQ,4CAA2C;AACtF,SACEC,0BAA0B,QAErB,kDAAiD;AACxD,SAASC,YAAY,QAAQ,iBAAa;AAC1C,SAASC,kBAAkB,EAAEC,wBAAwB,QAAQ,4BAAwB;AACrF,SAASC,gBAAgB,QAAQ,qBAAiB;AAClD,SAASC,yBAAyB,QAAQ,oCAAgC;AAE1E;;;;;;;;;;;;;;;;;;;;CAoBC,GACD,OAAO,MAAMC,yBAAwD;IACnEC,UAAUN;IACVO,YAAY;QACV;YACEC,KAAK;YACLC,OAAO;YACP,qEAAqE;YACrE,sEAAsE;YACtE,8CAA8C;YAC9CC,UAAUb;YACVc,OAAO;gBACLH,KAAK;gBACLI,SAASjB;YACX;YACAkB,UAAU;gBAAC;gBAAgB;aAAW;YACtCC,QAAQlB;QACV;KACD;IACDiB,UAAU;QACR;YAAEL,KAAK;YAAYC,OAAO;QAAY;QACtC;YAAED,KAAK;YAAgBC,OAAO;QAAgB;KAC/C;IACDM,kBAAkB;QAChB;YACEP,KAAK;YACLC,OAAO;YACPO,cAAc;YACdC,aAAa;YACbC,QAAQ;gBACNC,OAAO;gBACPC,MAAM;YACR;YACA,sEAAsE;YACtE,+BAA+B;YAC/B,oEAAoE;YACpE,8DAA8D;YAC9DC,UAAU;gBAAEC,OAAO;oBAAC;oBAAa;iBAAc;gBAAEC,UAAU;oBAAC;iBAAe;YAAC;QAC9E;QACA;YACEf,KAAK;YACLC,OAAO;YACPO,cAAc;YACdC,aAAa;YACbC,QAAQ;gBACNC,OAAO;gBACPC,MAAM;YACR;YACA,mEAAmE;YACnE,+DAA+D;YAC/DC,UAAU;gBAAEE,UAAU;oBAAC;oBAAe;oBAAW;iBAAS;YAAC;QAC7D;KACD;IACDC,gBAAgB;WAAIvB;WAAuBC;KAAyB;AACtE,EAAC;AAED,IAAIuB,WAAW;AAEf;;;;;;;CAOC,GACD,OAAO,SAASC;IACd,IAAID,UAAU;IACdA,WAAW;IACX1B,2BAA2BM;IAC3BP,2BAA2BK;IAC3BC;AACF;AAEAsB"}
@@ -0,0 +1,219 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { type SitePathListMode } from '@aglyn/aglyn/app-utils/site-path-patterns';
18
+ import type { SiteChatCapability, SiteChatCard, SiteChatProposal } from '@aglyn/aglyn/plugin-manager/plugin-site-chat-tools';
19
+ import type { OrgPlan } from '@aglyn/aglyn/foundation/definitions/org-billing.types';
20
+ /**
21
+ * Aglyn AI on a published site (AGL-4250): the owner's settings, the slice a
22
+ * page carries, the wire format, and the site-chat credit allotment. Free of
23
+ * any server or React dependency, so the console card, the site runtime and
24
+ * the door read one definition.
25
+ */
26
+ /** The visitor's door, on the published site only (`tenantApi`). */
27
+ export declare const SITE_CHAT_ROUTE = "ai/site-chat";
28
+ /** The owner's settings, on the console only (`consoleApi`). */
29
+ export declare const SITE_CHAT_SETTINGS_ROUTE = "ai/site-chat/settings";
30
+ /** The owner's conversations and figures, on the console only. */
31
+ export declare const SITE_CHAT_CONVERSATIONS_ROUTE = "ai/site-chat/conversations";
32
+ /** A visitor's own conversation so far, on the published site. */
33
+ export declare const SITE_CHAT_HISTORY_ROUTE = "ai/site-chat/history";
34
+ /** The release flag, off by default; a released-off door answers 404. */
35
+ export declare const SITE_CHAT_RELEASE_FLAG = "release_ai_site_chat";
36
+ /** The site runtime's id: `contributes.site.features`. */
37
+ export declare const SITE_CHAT_RUNTIME_ID = "ai-site-chat";
38
+ /** The page prop the enricher answers. */
39
+ export declare const SITE_CHAT_PAGE_PROP = "aiSiteChat";
40
+ /** The console widget on a site's settings page. */
41
+ export declare const SITE_CHAT_WIDGET_ID = "ai-site-chat-settings";
42
+ /** `hosts/{hostId}/pluginSettings/{SITE_CHAT_SETTINGS_DOC}`. */
43
+ export declare const SITE_CHAT_SETTINGS_COLLECTION = "pluginSettings";
44
+ export declare const SITE_CHAT_SETTINGS_DOC = "ai-site-chat";
45
+ /** `hosts/{hostId}/siteChats/{conversationId}`: one per visitor session. */
46
+ export declare const SITE_CHATS_COLLECTION = "siteChats";
47
+ /** `orgs/{orgId}/siteChatUsage/{YYYY-MM}`: the allotment's meter. */
48
+ export declare const SITE_CHAT_USAGE_COLLECTION = "siteChatUsage";
49
+ /** The visitor session cookie, per site. */
50
+ export declare const siteChatCookieName: (hostId: string) => string;
51
+ export declare const SITE_CHAT_GREETING_MAX = 200;
52
+ export declare const SITE_CHAT_OPENING_MAX = 400;
53
+ export declare const SITE_CHAT_CHIP_MAX = 40;
54
+ export declare const SITE_CHAT_CHIPS_MAX = 4;
55
+ export declare const SITE_CHAT_MAX_PATHS = 50;
56
+ export declare const SITE_CHAT_MAX_PATH_LENGTH = 200;
57
+ /** What one visitor message may carry. */
58
+ export declare const SITE_CHAT_MESSAGE_MAX = 1000;
59
+ /** Turns one conversation may take in a day. */
60
+ export declare const SITE_CHAT_TURNS_PER_CONVERSATION = 30;
61
+ /** Turns the history keeps verbatim for the model. */
62
+ export declare const SITE_CHAT_HISTORY_TURNS = 8;
63
+ export declare const SITE_CHAT_DEFAULT_GREETING = "Hi! Ask me anything about us.";
64
+ export type SiteChatPosition = 'right' | 'left';
65
+ export interface SiteChatSettings {
66
+ enabled: boolean;
67
+ /** The first line in the panel. */
68
+ greeting: string;
69
+ /**
70
+ * The owner's opening message, shown once per visitor before they ask
71
+ * anything (a promotion, an announcement). '' for none.
72
+ */
73
+ openingMessage: string;
74
+ /** Suggested questions under the greeting. */
75
+ chips: string[];
76
+ /** What the chat may do besides answering. */
77
+ capabilities: SiteChatCapability[];
78
+ pages: SitePathListMode;
79
+ paths: string[];
80
+ position: SiteChatPosition;
81
+ /**
82
+ * The owner's own ceiling on what visitor chats may spend in a month, in
83
+ * credits, under the plan's site-chat allotment; `null` for the allotment.
84
+ */
85
+ monthlyCreditCap: number | null;
86
+ /** Hand a visitor to a person (the Inbox) when the chat cannot help. */
87
+ handOff: boolean;
88
+ }
89
+ export declare const SITE_CHAT_DEFAULT_SETTINGS: SiteChatSettings;
90
+ export type SiteChatSettingsResult = {
91
+ settings: SiteChatSettings;
92
+ } | {
93
+ error: string;
94
+ };
95
+ export declare function normalizeSiteChatSettings(input: unknown): SiteChatSettingsResult;
96
+ /** A stored document read back; anything unreadable is the defaults, off. */
97
+ export declare function readStoredSiteChatSettings(stored: unknown): SiteChatSettings;
98
+ /** What a page the chat shows on carries for the runtime. */
99
+ export interface SiteChatSlice {
100
+ greeting: string;
101
+ openingMessage: string;
102
+ chips: string[];
103
+ capabilities: SiteChatCapability[];
104
+ position: SiteChatPosition;
105
+ handOff: boolean;
106
+ }
107
+ export declare function siteChatSliceForPage(settings: SiteChatSettings, path: string, pathUnknown?: boolean): SiteChatSlice | null;
108
+ /** A slice off the page props, checked; `null` for anything else. */
109
+ export declare function readSiteChatSlice(value: unknown): SiteChatSlice | null;
110
+ /**
111
+ * Credits a month visitor chats may spend, by plan. They are the workspace's
112
+ * own AI credits (one pool, billed as every other AI request is), held under
113
+ * their own hard cap so a busy site can never drain what the team's console
114
+ * assistant runs on. Free has none: site chat is a Starter-and-up feature.
115
+ * An owner may set a lower cap per site; nothing raises it past these.
116
+ */
117
+ export declare const SITE_CHAT_CREDITS_BY_PLAN: Readonly<Record<OrgPlan, number>>;
118
+ /** The plan's allotment, `0` for a plan without site chat. */
119
+ export declare function siteChatPlanCredits(plan: OrgPlan | string | null | undefined): number;
120
+ /** Whether the plan includes site chat at all. */
121
+ export declare function siteChatOnPlan(plan: OrgPlan | string | null | undefined): boolean;
122
+ /**
123
+ * The ceiling one site's chats spend against this month: the plan's
124
+ * allotment for the workspace, narrowed by the site owner's own cap.
125
+ */
126
+ export declare function siteChatCeiling(planCredits: number, ownerCap: number | null | undefined): number;
127
+ /**
128
+ * Credits held for one turn before it runs. A turn costs a few credits on the
129
+ * fast tier; the hold is the most a turn is allowed to cost, so the cap can
130
+ * be passed by at most one turn's difference while two run at once.
131
+ */
132
+ export declare const SITE_CHAT_TURN_HOLD_CREDITS = 40;
133
+ /** A visitor's turn as the widget posts it. */
134
+ export interface SiteChatRequestBody {
135
+ hostId: string;
136
+ message: string;
137
+ /** The page the visitor is on, for "this page" questions. */
138
+ path?: string;
139
+ }
140
+ /**
141
+ * The events the door streams, one per `data:` line, the shape console
142
+ * Assist streams: text arrives as `delta`s and the turn ends with `done`.
143
+ */
144
+ export type SiteChatEvent = {
145
+ type: 'delta';
146
+ text: string;
147
+ } | {
148
+ type: 'cards';
149
+ cards: SiteChatCard[];
150
+ } | {
151
+ type: 'proposal';
152
+ proposal: SiteChatProposal;
153
+ } | {
154
+ type: 'handoff';
155
+ message: string;
156
+ } | {
157
+ type: 'done';
158
+ conversationId: string;
159
+ sources: SiteChatSource[];
160
+ } | {
161
+ type: 'error';
162
+ error: string;
163
+ reason?: string;
164
+ };
165
+ /** A page the answer used, linked under it. */
166
+ export interface SiteChatSource {
167
+ title: string;
168
+ url: string;
169
+ }
170
+ /** One stored turn of a conversation. */
171
+ export interface SiteChatTurn {
172
+ role: 'visitor' | 'assistant';
173
+ text: string;
174
+ at: number;
175
+ cards?: SiteChatCard[];
176
+ proposal?: SiteChatProposal;
177
+ sources?: SiteChatSource[];
178
+ }
179
+ /** What the console lists for a conversation. */
180
+ export interface SiteChatConversationSummary {
181
+ id: string;
182
+ startedAt: number;
183
+ updatedAt: number;
184
+ turns: number;
185
+ firstQuestion: string;
186
+ /** A proposal the visitor was shown, by kind. */
187
+ proposals: number;
188
+ handedOff: boolean;
189
+ member?: {
190
+ name: string;
191
+ } | null;
192
+ }
193
+ /** What a refusal says to a visitor; never a reason only staff should see. */
194
+ export declare const SITE_CHAT_UNAVAILABLE_COPY = "The chat is not available right now. Please call or email us, and we will be glad to help.";
195
+ export declare const SITE_CHAT_BUSY_COPY = "Lots of questions right now. Please try again in a minute.";
196
+ export declare const SITE_CHAT_CONVERSATION_LIMIT_COPY = "We have covered a lot today. For anything else, please call or email us.";
197
+ /** One site's month, for the owner's card. */
198
+ export interface SiteChatMonth {
199
+ month: string;
200
+ credits: number;
201
+ questions: number;
202
+ proposals: number;
203
+ conversations: number;
204
+ /** What the workspace's sites spent together. */
205
+ workspaceCredits: number;
206
+ }
207
+ /** What the owner's settings door answers. */
208
+ export interface SiteChatSettingsAnswer {
209
+ settings: SiteChatSettings;
210
+ canManage: boolean;
211
+ /** The plan includes site chat (Starter and up). */
212
+ onPlan: boolean;
213
+ /** The release flag is on for the workspace. */
214
+ released: boolean;
215
+ /** The plan's allotment, the ceiling this site spends against, and the month. */
216
+ planCredits: number;
217
+ ceiling: number;
218
+ month: SiteChatMonth | null;
219
+ }