@sentientui/react 0.39.0 → 0.40.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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/devtools/index.tsx","../src/devtools-registry.ts","../src/devtools-overrides.ts","../src/devtools-slot-overrides.ts","../src/preview-mode.ts","../src/override-events.ts","../src/devtools-config.ts"],"sourcesContent":["'use client';\n// `type JSX` from react, not the global namespace removed in @types/react@19\n// (peers allow react >=18) — see adaptive-text.tsx.\nimport { useEffect, useReducer, useState, useSyncExternalStore, type CSSProperties, type JSX } from 'react';\nimport { UNKNOWN_PERSONA, UNKNOWN_PERSONA_DISPLAY, confidenceBand, normalizeDeclaredPersona } from '@sentientui/policy';\nimport { LEGACY_SESSION_COOKIE_NAME, SNAPSHOT_STORAGE_KEY_PREFIX, sessionCookieName } from '@sentientui/core';\nimport {\n getRegistered,\n getRegisteredSlots,\n getRegisteredSections,\n subscribeRegistry,\n getRegistryVersion,\n type RegisteredSlot,\n} from '../devtools-registry.js';\nimport { setVariantOverride, clearVariantOverride, getOverrides } from '../devtools-overrides.js';\nimport { setSlotOverride, clearSlotOverride, getSlotOverrides } from '../devtools-slot-overrides.js';\nimport { setPreviewMode, getPreviewMode } from '../preview-mode.js';\nimport { notifyOverridesChanged } from '../override-events.js';\nimport { readDevtoolsConfig, type DevtoolsConfig } from '../devtools-config.js';\n\ndeclare const process: { env?: { NODE_ENV?: string } } | undefined;\nconst IS_PROD = typeof process !== 'undefined' && process.env?.NODE_ENV === 'production';\nconst DEFAULT_API_BASE_URL = 'https://api.sentient-ui.com/v1';\n\nexport const LOCAL_MODE_DEVTOOLS_BANNER =\n 'Local mode — decisions are simulated; add a key to learn from real traffic';\n\ntype OutcomeToApply = {\n assignments?: Record<string, string>;\n layoutOrder?: string[] | null;\n slots?: Record<string, string | Record<string, string>>;\n personaAttributes?: { persona: string; confidence: 'low' | 'medium' | 'high' };\n};\n\ntype OverrideWindow = Window & {\n __sentient_layout_override?: string[];\n __sentient_slot_overrides?: Record<string, string | Record<string, string>>;\n};\n\n/** The order the page is rendering: a previewed override, else what was registered. */\nfunction currentLayout(): string[] {\n const forced = (window as unknown as OverrideWindow).__sentient_layout_override;\n const registered = getRegisteredSections();\n if (!forced || forced.length === 0) return registered;\n // Registered ids the override omits still render (useLayoutOrder returns the\n // override verbatim, and the app maps whatever ids it is given), so show them\n // trailing rather than dropping them from the list you are dragging.\n return [...forced, ...registered.filter((id) => !forced.includes(id))];\n}\n\n/**\n * Move `from` to `to` within the current order and preview it.\n *\n * Writes the whole order rather than swapping neighbours: the point is to try an\n * arrangement, not to walk one block up a list one press at a time.\n */\nfunction reorderLayout(from: number, to: number): void {\n const order = currentLayout();\n if (from === to || from < 0 || to < 0 || from >= order.length || to >= order.length) return;\n const next = [...order];\n const [moved] = next.splice(from, 1);\n next.splice(to, 0, moved!);\n (window as unknown as OverrideWindow).__sentient_layout_override = next;\n setPreviewMode(true); // an arrangement you are trying must not train the bandit\n notifyOverridesChanged();\n}\n\nfunction resetLayout(): void {\n delete (window as unknown as OverrideWindow).__sentient_layout_override;\n notifyOverridesChanged();\n}\n\n/** Apply a simulated outcome across every surface: variants, layout, slots/tokens, persona attrs. */\nfunction applyOutcome(result: OutcomeToApply): void {\n for (const [id, variantId] of Object.entries(result.assignments ?? {})) {\n setVariantOverride(id, variantId);\n }\n const w = window as unknown as OverrideWindow;\n if (result.layoutOrder && result.layoutOrder.length > 0) {\n w.__sentient_layout_override = result.layoutOrder;\n }\n if (result.slots) {\n w.__sentient_slot_overrides = { ...(w.__sentient_slot_overrides ?? {}), ...result.slots };\n }\n if (result.personaAttributes) {\n document.documentElement.dataset.sentientPersona = result.personaAttributes.persona;\n document.documentElement.dataset.sentientConfidence = result.personaAttributes.confidence;\n }\n setPreviewMode(true); // suppress events while previewing\n notifyOverridesChanged(); // re-render layout/slot consumers\n}\n\n// Reads the SDK's own session cookie — the per-project SUFFIXED name first\n// (that is what the client writes since namespacing; the bare `_snt_uid` this\n// used to read is only written in keyless/local mode), then the bare name as\n// the legacy/local fallback.\nfunction readSessionId(apiKey?: string): string {\n const read = (name: string): string | null => {\n try {\n const match = document.cookie.match(new RegExp(`(?:^|; )${name}=([^;]*)`));\n return match ? decodeURIComponent(match[1]!) : null;\n } catch {\n return null;\n }\n };\n return (apiKey ? read(sessionCookieName(apiKey)) : null) ?? read(LEGACY_SESSION_COOKIE_NAME) ?? 'devtools-preview';\n}\n\nfunction slotDecls(): Array<{ id: string; arms?: string[]; dims?: RegisteredSlot['dims'] }> {\n return getRegisteredSlots().map((s) => ({\n id: s.id,\n ...(s.arms ? { arms: s.arms } : {}),\n ...(s.dims ? { dims: s.dims } : {}),\n }));\n}\n\n/** One member of the project's persona vocabulary, as /v1/personas serves it. */\ntype VocabMember = { key: string; displayName: string };\n\n/** Always offered: previewing the unidentified visitor is meaningful on every\n * project, and it is the only persona the product itself defines. */\nconst UNKNOWN_CHOICE: VocabMember = { key: UNKNOWN_PERSONA, displayName: UNKNOWN_PERSONA_DISPLAY };\n\n/**\n * Keyed mode: the project's ACTIVE vocabulary from /v1/personas. Personas are\n * per-project (persona_sets, migration 113) — declared by the app or promoted\n * by discovery. This used to fall back to a hardcoded list of four seeded\n * personas, which offered buttons that silently simulated the default\n * experience on any project whose vocabulary differs, and named audiences\n * nobody had declared. null on any failure → the panel offers only `unknown`\n * and a free-text key.\n */\nasync function fetchPersonaVocabulary(\n apiKey: string,\n apiBaseUrl: string,\n): Promise<{ personas: VocabMember[]; discovered: VocabMember[] } | null> {\n try {\n const res = await fetch(`${apiBaseUrl}/personas`, {\n headers: { authorization: `Bearer ${apiKey}` },\n });\n if (!res.ok) return null;\n const data = (await res.json()) as { personas?: VocabMember[]; discovered?: VocabMember[] };\n const valid = (list: VocabMember[] | undefined): VocabMember[] =>\n Array.isArray(list)\n ? list.filter((p) => p && typeof p.key === 'string' && typeof p.displayName === 'string')\n : [];\n const personas = valid(data.personas);\n return personas.length > 0 ? { personas, discovered: valid(data.discovered) } : null;\n } catch {\n return null;\n }\n}\n\n/**\n * `?sentient_context=<context>` on the page URL: the on-site context preview\n * (a stage such as `carted`, or an arrival class such as `cart_recovery`).\n * Forwarded to /v1/explain so a persona simulated from this panel is also\n * simulated in that context — the API validates the value (400 on anything\n * else) and applies it to the project's published (registry) versions:\n * those restricted to the context become eligible and its pins win. Lives\n * here, not in the provider: devtools is the React SDK's only explain-backed\n * preview, and the main bundle pays for nothing it does not use.\n * @internal Exported for tests.\n */\nexport function previewContextParam(): string | null {\n try {\n const v = new URLSearchParams(window.location.search).get('sentient_context');\n return v && /^[a-z_]{1,40}$/.test(v) ? v : null;\n } catch {\n return null;\n }\n}\n\n/** Keyed mode: simulate via /v1/explain (read-only, event-free). Returns how\n * the persona RESOLVED so the panel can say when the project didn't\n * recognize it — the page then shows the default experience, and a silently\n * highlighted button claiming otherwise was the old lie. */\nasync function forcePersonaKeyed(\n apiKey: string,\n apiBaseUrl: string,\n persona: string,\n): Promise<{ recognized: boolean; resolvedDisplay: string } | null> {\n const res = await fetch(`${apiBaseUrl}/explain`, {\n method: 'POST',\n headers: { 'content-type': 'application/json', authorization: `Bearer ${apiKey}` },\n body: JSON.stringify({\n persona,\n sections: getRegisteredSections().map((id) => ({ id })),\n components: getRegistered().map((c) => ({ id: c.id, variantIds: c.variantIds })),\n slots: slotDecls(),\n ...(previewContextParam() ? { context: previewContextParam() } : {}),\n }),\n });\n if (!res.ok) return null;\n const data = (await res.json()) as OutcomeToApply & {\n recognized?: boolean;\n persona?: string;\n personaDisplay?: string;\n };\n applyOutcome({\n ...data,\n personaAttributes: data.personaAttributes ?? { persona, confidence: 'high' },\n });\n return {\n // An older API omits the field — treat as recognized (no basis to warn).\n recognized: data.recognized !== false,\n resolvedDisplay: data.personaDisplay ?? data.persona ?? persona,\n };\n}\n\n/** Local mode: simulate via the deterministic local engine — zero network. */\nasync function forcePersonaLocal(persona: string, apiKey?: string): Promise<void> {\n const mod = await import('@sentientui/core/local');\n if (!mod.LOCAL_ENGINE_AVAILABLE) return;\n const outcome = mod\n .createLocalEngine({ sessionId: readSessionId(apiKey), forcedPersona: persona })\n .decide({\n sections: getRegisteredSections(),\n components: getRegistered().map((c) => ({ id: c.id, variantIds: c.variantIds })),\n slots: slotDecls(),\n });\n applyOutcome({\n assignments: outcome.assignments,\n layoutOrder: outcome.layoutOrder,\n slots: outcome.slots,\n personaAttributes: {\n persona: outcome.persona,\n confidence: confidenceBand(outcome.confidence),\n },\n });\n}\n\n/** Reset: clear the decision snapshot + every override, then reload to re-decide. */\nfunction resetAll(): void {\n for (const id of Object.keys(getOverrides())) clearVariantOverride(id);\n const w = window as unknown as OverrideWindow;\n delete w.__sentient_layout_override;\n delete w.__sentient_slot_overrides;\n delete document.documentElement.dataset.sentientPersona;\n delete document.documentElement.dataset.sentientConfidence;\n try {\n const stale: string[] = [];\n for (let i = 0; i < localStorage.length; i++) {\n const key = localStorage.key(i);\n if (key && key.startsWith(SNAPSHOT_STORAGE_KEY_PREFIX)) stale.push(key);\n }\n for (const key of stale) localStorage.removeItem(key);\n } catch {\n /* ignore */\n }\n setPreviewMode(false);\n notifyOverridesChanged();\n try {\n window.location.reload();\n } catch {\n /* jsdom */\n }\n}\n\nconst btn = (active: boolean): CSSProperties => ({\n padding: '2px 8px',\n borderRadius: 4,\n border: '1px solid #444',\n background: active ? '#3b82f6' : '#222',\n color: '#eee',\n cursor: 'pointer',\n});\n\n/** Sentient \"S.\" wordmark, monoline — white strokes for the black launcher button. */\nfunction SentientMark({ size = 26 }: { size?: number } = {}): JSX.Element {\n return (\n <svg width={size} height={size} viewBox=\"0 0 32 32\" fill=\"none\" aria-hidden=\"true\">\n <path\n d=\"M21 9H14C11.2 9 9.8 10.8 9.8 13C9.8 15.4 11.6 16.6 14.5 16.6H18.5C20.5 16.6 20.7 18.2 20.4 19.6\"\n stroke=\"#fff\"\n strokeWidth=\"2.2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n <path d=\"M10 22H17\" stroke=\"#fff\" strokeWidth=\"2.2\" strokeLinecap=\"round\" />\n <circle cx=\"20.6\" cy=\"22\" r=\"2.1\" fill=\"#fff\" />\n </svg>\n );\n}\n\nexport function AdaptiveDevtools({ apiKey }: { apiKey?: string } = {}): JSX.Element | null {\n const [open, setOpen] = useState(false);\n const [activePersona, setActivePersona] = useState<string | null>(null);\n // The project's vocabulary (keyed mode); null = not loaded → no persona\n // buttons beyond `unknown`. Local mode never fetches: there is no project,\n // and the local engine previews ANY key typed into the free-text field.\n const [vocab, setVocab] = useState<VocabMember[] | null>(null);\n const [customKey, setCustomKey] = useState('');\n // Discovered SHADOW personas — display-only. They never serve until\n // promotion, so there is no button: forcing one would simulate a persona\n // that cannot occur on this project.\n const [discovered, setDiscovered] = useState<VocabMember[]>([]);\n // Set when a forced persona did NOT resolve against the project's\n // vocabulary — the page is showing the default experience and the panel\n // must say so instead of highlighting the button as if the preview worked.\n const [personaNote, setPersonaNote] = useState<string | null>(null);\n const [dragFrom, setDragFrom] = useState<number | null>(null);\n const [mounted, setMounted] = useState(false);\n const [, force] = useReducer((n: number) => n + 1, 0);\n // Re-render when the component/slot registry changes. useSyncExternalStore\n // (not a manual useEffect subscription) so the subscription can't go stale\n // across Next Fast Refresh — a stale listener was why the panel needed a hard\n // refresh to pick up a renamed id.\n useSyncExternalStore(subscribeRegistry, getRegistryVersion, () => 0);\n // Client-mount gate: render nothing during SSR / the first paint so the widget\n // never reads `window` on the server. Lets consumers drop `<AdaptiveDevtools/>`\n // straight into a tree without a `dynamic(..., { ssr: false })` wrapper.\n useEffect(() => setMounted(true), []);\n // Load the project's persona vocabulary once (keyed mode only).\n useEffect(() => {\n if (IS_PROD) return;\n const cfg = readDevtoolsConfig() ?? { apiKey: apiKey ?? '', apiBaseUrl: DEFAULT_API_BASE_URL, isLocal: false };\n if (cfg.isLocal || !cfg.apiKey) return;\n let cancelled = false;\n void fetchPersonaVocabulary(cfg.apiKey, cfg.apiBaseUrl).then((v) => {\n if (cancelled || !v) return;\n setVocab(v.personas);\n setDiscovered(v.discovered);\n });\n return () => { cancelled = true; };\n }, [apiKey]);\n\n // Never render in production, even if imported by mistake. (Hooks run first\n // so the rules of hooks hold regardless of these early returns.)\n if (IS_PROD) return null;\n if (!mounted) return null;\n\n const config: DevtoolsConfig = readDevtoolsConfig() ?? {\n apiKey: apiKey ?? '',\n apiBaseUrl: DEFAULT_API_BASE_URL,\n isLocal: false,\n };\n const useLocalEngine = config.isLocal || !config.apiKey;\n const components = getRegistered();\n const slots = getRegisteredSlots();\n const overrides = getOverrides();\n const slotOverrides = getSlotOverrides();\n const sections = currentLayout();\n const layoutForced = (window as unknown as OverrideWindow).__sentient_layout_override !== undefined;\n\n function onReorder(from: number, to: number): void {\n reorderLayout(from, to);\n force();\n }\n function onResetLayout(): void {\n resetLayout();\n maybeExitPreview();\n force();\n }\n\n // Preview mode stays on while ANY override (variant, slot or layout) is\n // active. Omitting layout here let clearing the last variant re-enable event\n // recording while a previewed section order was still on screen.\n function maybeExitPreview(): void {\n if (\n Object.keys(getOverrides()).length === 0 &&\n Object.keys(getSlotOverrides()).length === 0 &&\n (window as unknown as OverrideWindow).__sentient_layout_override === undefined\n ) {\n setPreviewMode(false);\n }\n }\n\n function choose(id: string, variantId: string): void {\n setVariantOverride(id, variantId);\n setPreviewMode(true);\n notifyOverridesChanged();\n force();\n }\n function resetVariant(id: string): void {\n clearVariantOverride(id);\n maybeExitPreview();\n notifyOverridesChanged();\n force();\n }\n function chooseSlotArm(id: string, arm: string): void {\n setSlotOverride(id, arm);\n setPreviewMode(true);\n notifyOverridesChanged();\n force();\n }\n function chooseSlotDim(id: string, dim: string, value: string, dims: RegisteredSlot['dims']): void {\n const current = getSlotOverrides()[id];\n // Merge onto the existing forced object, or seed from each dim's baseline\n // (first value) so unset dims stay at baseline instead of vanishing.\n const next: Record<string, string> =\n current && typeof current === 'object'\n ? { ...current }\n : Object.fromEntries(Object.entries(dims ?? {}).map(([d, values]) => [d, values[0]!]));\n next[dim] = value;\n setSlotOverride(id, next);\n setPreviewMode(true);\n notifyOverridesChanged();\n force();\n }\n function resetSlot(id: string): void {\n clearSlotOverride(id);\n maybeExitPreview();\n notifyOverridesChanged();\n force();\n }\n function choosePersona(member: VocabMember): void {\n setActivePersona(member.key);\n setPersonaNote(null);\n // .catch: a failed simulate (offline /v1/explain, bad key, failed local\n // dynamic import) is a preview no-op — without the handler it surfaced as\n // an unhandled promise rejection in the console.\n if (useLocalEngine) {\n forcePersonaLocal(member.key, config.apiKey).then(force).catch(() => {});\n return;\n }\n forcePersonaKeyed(config.apiKey, config.apiBaseUrl, member.key)\n .then((r) => {\n if (r && !r.recognized) {\n setPersonaNote(\n `“${member.displayName}” isn’t in this project’s personas — the page is showing the default experience.`,\n );\n }\n force();\n })\n .catch(() => {});\n }\n\n return (\n <div style={{ position: 'fixed', bottom: 16, right: 16, zIndex: 2147483647, fontFamily: 'system-ui' }}>\n {/* Panel stays mounted and animates in/out from the button's corner, so the\n launcher below never shifts. transform-origin is the button (bottom-right). */}\n <div\n aria-hidden={!open}\n style={{\n position: 'absolute',\n bottom: 52,\n right: 0,\n transformOrigin: 'bottom right',\n transition: 'opacity .18s ease, transform .2s cubic-bezier(.16,1,.3,1)',\n opacity: open ? 1 : 0,\n transform: open ? 'translateY(0) scale(1)' : 'translateY(6px) scale(.96)',\n pointerEvents: open ? 'auto' : 'none',\n }}\n >\n <div style={{ width: 300, maxHeight: 460, overflowY: 'auto', background: '#111', color: '#eee',\n borderRadius: 8, padding: 12, boxShadow: '0 8px 30px rgba(0,0,0,.4)', fontSize: 12 }}>\n {config.isLocal && (\n <div style={{ background: '#1e293b', border: '1px solid #334155', borderRadius: 4,\n padding: '6px 8px', marginBottom: 8 }}>\n {LOCAL_MODE_DEVTOOLS_BANNER}\n </div>\n )}\n <div style={{ opacity: .7, marginBottom: 8 }}>\n {components.length} component{components.length === 1 ? '' : 's'} · {getPreviewMode() ? 'preview — writing nothing' : 'live'}\n </div>\n <div style={{ borderBottom: '1px solid #333', paddingBottom: 8, marginBottom: 8 }}>\n <div style={{ opacity: .7, marginBottom: 4 }}>Preview persona</div>\n <div style={{ display: 'flex', flexWrap: 'wrap', gap: 4 }}>\n {/* Keyed mode renders the project's OWN vocabulary once\n /v1/personas answers; nothing is invented while it hasn't. */}\n {[...(useLocalEngine ? [] : vocab ?? []), UNKNOWN_CHOICE].map((p) => (\n <button key={p.key} onClick={() => choosePersona(p)} style={btn(activePersona === p.key)}>\n {p.displayName}\n </button>\n ))}\n {(activePersona !== null || Object.keys(overrides).length > 0 || Object.keys(slotOverrides).length > 0) && (\n <button onClick={resetAll} style={{ ...btn(false), color: '#aaa' }}>\n Reset\n </button>\n )}\n </div>\n <form\n onSubmit={(e) => {\n e.preventDefault();\n const key = normalizeDeclaredPersona(customKey);\n if (key) choosePersona({ key, displayName: key });\n }}\n style={{ display: 'flex', gap: 4, marginTop: 6 }}\n >\n <input\n aria-label=\"Persona key\"\n placeholder=\"any persona key, e.g. admin\"\n value={customKey}\n onChange={(e) => setCustomKey(e.target.value)}\n style={{ flex: 1, minWidth: 0, background: '#111', color: '#fff', border: '1px solid #333',\n borderRadius: 4, padding: '4px 6px', fontSize: 12 }}\n />\n <button type=\"submit\" style={btn(false)}>Preview</button>\n </form>\n {personaNote && (\n <div style={{ marginTop: 6, fontSize: 11, color: '#fbbf24' }}>{personaNote}</div>\n )}\n {!useLocalEngine && discovered.length > 0 && (\n <div style={{ marginTop: 8 }}>\n <div style={{ opacity: .5, fontSize: 11, marginBottom: 4 }}>\n Discovered — not serving yet (promote from the dashboard)\n </div>\n <div style={{ display: 'flex', flexWrap: 'wrap', gap: 4 }}>\n {discovered.map((p) => (\n <span\n key={p.key}\n title=\"Found by clustering your traffic; it starts serving only after promotion.\"\n style={{ ...btn(false), opacity: .45, cursor: 'default', display: 'inline-block' }}\n >\n {p.displayName}\n </span>\n ))}\n </div>\n </div>\n )}\n </div>\n {sections.length > 0 && (\n <div style={{ borderBottom: '1px solid #333', paddingBottom: 8, marginBottom: 8 }}>\n <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', marginBottom: 4 }}>\n <span style={{ opacity: .7 }}>Layout — drag to reorder</span>\n {layoutForced && (\n // Distinct accessible name: the per-variant and per-slot resets\n // below are also labelled \"reset\", and three identical buttons\n // in one panel is ambiguous to a screen reader and to tests.\n <button\n aria-label=\"Reset section order\"\n onClick={onResetLayout}\n style={{ ...btn(false), color: '#aaa' }}\n >\n reset\n </button>\n )}\n </div>\n {/* Drop-on-row inserts at that row's position, so any block can go\n anywhere in one gesture. The whole order is written on each\n drop — see reorderLayout. */}\n <ul aria-label=\"Section order\" style={{ listStyle: 'none', margin: 0, padding: 0 }}>\n {sections.map((id, i) => (\n <li\n key={id}\n draggable\n onDragStart={() => setDragFrom(i)}\n onDragOver={(e) => e.preventDefault()}\n onDrop={(e) => {\n e.preventDefault();\n if (dragFrom !== null) onReorder(dragFrom, i);\n setDragFrom(null);\n }}\n onDragEnd={() => setDragFrom(null)}\n style={{\n display: 'flex', alignItems: 'center', gap: 6, padding: '4px 6px', marginBottom: 2,\n borderRadius: 4, border: '1px solid #262626', cursor: 'grab',\n background: dragFrom === i ? '#1e293b' : '#181818',\n opacity: dragFrom !== null && dragFrom !== i ? .6 : 1,\n }}\n >\n <span style={{ opacity: .4, minWidth: 10, fontVariantNumeric: 'tabular-nums' }}>{i + 1}</span>\n <span aria-hidden=\"true\" style={{ opacity: .35 }}>⠿</span>\n <span style={{ flex: 1, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>\n {id}\n </span>\n </li>\n ))}\n </ul>\n </div>\n )}\n {components.length === 0 && slots.length === 0 && sections.length === 0 && (\n <div style={{ opacity: .6 }}>No components, sections or slots on this page yet.</div>\n )}\n {components.map((c) => (\n <div key={c.id} style={{ borderTop: '1px solid #333', padding: '8px 0' }}>\n <div style={{ fontWeight: 600 }}>{c.id}{c.goal ? ` · goal: ${c.goal}` : ''}</div>\n <div style={{ display: 'flex', flexWrap: 'wrap', gap: 4, marginTop: 4 }}>\n {c.variantIds.map((v) => (\n <button key={v} onClick={() => choose(c.id, v)} style={btn(overrides[c.id] === v)}>\n {v}\n </button>\n ))}\n {overrides[c.id] && (\n <button onClick={() => resetVariant(c.id)} style={{ ...btn(false), color: '#aaa' }}>\n reset\n </button>\n )}\n </div>\n </div>\n ))}\n {slots.length > 0 && (\n <div style={{ borderTop: '1px solid #333', paddingTop: 8, marginTop: 4 }}>\n <div style={{ opacity: .7, marginBottom: 4 }}>Slots</div>\n {slots.map((s) => {\n const ov = slotOverrides[s.id];\n return (\n <div key={s.id} style={{ padding: '6px 0' }}>\n <div style={{ fontWeight: 600 }}>{s.id}</div>\n {s.arms && (\n <div style={{ display: 'flex', flexWrap: 'wrap', gap: 4, marginTop: 4 }}>\n {s.arms.map((arm) => (\n <button key={arm} onClick={() => chooseSlotArm(s.id, arm)} style={btn(ov === arm)}>\n {arm}\n </button>\n ))}\n </div>\n )}\n {s.dims && Object.entries(s.dims).map(([dim, values]) => (\n <div key={dim} style={{ marginTop: 4 }}>\n <div style={{ opacity: .6, fontSize: 11 }}>{dim}</div>\n <div style={{ display: 'flex', flexWrap: 'wrap', gap: 4 }}>\n {values.map((v) => (\n <button\n key={v}\n onClick={() => chooseSlotDim(s.id, dim, v, s.dims)}\n style={btn(!!ov && typeof ov === 'object' && ov[dim] === v)}\n >\n {v}\n </button>\n ))}\n </div>\n </div>\n ))}\n {ov !== undefined && (\n <button onClick={() => resetSlot(s.id)} style={{ ...btn(false), color: '#aaa', marginTop: 4 }}>\n reset\n </button>\n )}\n </div>\n );\n })}\n </div>\n )}\n </div>\n </div>\n <button\n aria-label=\"Sentient DevTools\"\n aria-expanded={open}\n onClick={() => setOpen((o) => !o)}\n style={{ width: 44, height: 44, borderRadius: 12, border: '1px solid #2a2a2a', background: '#000',\n display: 'flex', alignItems: 'center', justifyContent: 'center', padding: 0,\n cursor: 'pointer', boxShadow: '0 6px 18px rgba(0,0,0,.4)' }}\n >\n <SentientMark />\n </button>\n </div>\n );\n}\n","import { isDevBuild } from './adaptive-shared.js';\n\nexport type RegisteredComponent = { id: string; variantIds: string[]; goal?: string };\nexport type RegisteredSlot = {\n id: string;\n arms?: string[];\n dims?: Record<string, readonly string[]>;\n};\n\ntype RegistryState = {\n components: Map<string, RegisteredComponent>;\n slots: Map<string, RegisteredSlot>;\n sections: string[];\n listeners: Set<() => void>;\n /** Bumped on every mutation so `useSyncExternalStore` can read a stable, comparable snapshot. */\n version: number;\n};\n\n// Shared through a window global: the main entry and the /devtools entry are\n// separate bundles, each with its own copy of this module — module-local\n// state would give the devtools an always-empty registry in published apps.\nconst ssrFallback: RegistryState = {\n components: new Map(),\n slots: new Map(),\n sections: [],\n listeners: new Set(),\n version: 0,\n};\n\nfunction state(): RegistryState {\n if (typeof window === 'undefined') return ssrFallback;\n const w = window as unknown as { __sentient_registry?: RegistryState };\n if (!w.__sentient_registry) {\n w.__sentient_registry = {\n components: new Map(),\n slots: new Map(),\n sections: [],\n listeners: new Set(),\n version: 0,\n };\n }\n return w.__sentient_registry;\n}\n\nfunction emit(): void {\n // Bump BEFORE notifying so a useSyncExternalStore consumer re-reading its\n // snapshot inside the notification sees the new value and re-renders.\n state().version += 1;\n for (const fn of state().listeners) fn();\n}\n\n// The registry exists solely to feed the opt-in devtools panel, which is a\n// dev-only surface. In a production build there is no panel reading it, so\n// every register call is dead work plus a `window.__sentient_registry`\n// footprint on the customer's page. Short-circuit to a noop in production —\n// every <Adaptive>/useAdaptive/slot mount calls one of these.\nconst NOOP_UNREGISTER = (): void => undefined;\n\n/** Register (or re-register) a component. Returns an unregister function. */\nexport function registerComponent(c: RegisteredComponent): () => void {\n if (!isDevBuild()) return NOOP_UNREGISTER;\n state().components.set(c.id, c);\n emit();\n return () => {\n state().components.delete(c.id);\n emit();\n };\n}\n\n/** Register (or re-register) a slot declaration. Returns an unregister function. */\nexport function registerSlot(s: RegisteredSlot): () => void {\n if (!isDevBuild()) return NOOP_UNREGISTER;\n state().slots.set(s.id, s);\n emit();\n return () => {\n state().slots.delete(s.id);\n emit();\n };\n}\n\n/** Register the page's declared section ids (from AdaptiveRoot/provider). */\nexport function registerSections(sections: string[]): void {\n if (!isDevBuild()) return;\n state().sections = [...sections];\n emit();\n}\n\nexport function getRegistered(): RegisteredComponent[] {\n return [...state().components.values()];\n}\n\nexport function getRegisteredSlots(): RegisteredSlot[] {\n return [...state().slots.values()];\n}\n\nexport function getRegisteredSections(): string[] {\n return [...state().sections];\n}\n\nexport function subscribeRegistry(fn: () => void): () => void {\n const listeners = state().listeners;\n listeners.add(fn);\n return () => {\n listeners.delete(fn);\n };\n}\n\n/** Monotonic snapshot for `useSyncExternalStore` — changes on every registry mutation. */\nexport function getRegistryVersion(): number {\n return state().version;\n}\n","function store(): Record<string, string> {\n const w = window as unknown as { __sentient_overrides?: Record<string, string> };\n if (!w.__sentient_overrides) w.__sentient_overrides = {};\n return w.__sentient_overrides;\n}\n\n/** Force `componentId` to render `variantId` — read by `useAssignment`. */\nexport function setVariantOverride(componentId: string, variantId: string): void {\n store()[componentId] = variantId;\n}\n\nexport function clearVariantOverride(componentId: string): void {\n delete store()[componentId];\n}\n\nexport function getOverrides(): Record<string, string> {\n return { ...store() };\n}\n","import type { SlotResult } from '@sentientui/core';\n\n/**\n * Slot-override store — the channel `useSlotResult` reads (`useAdaptiveTokens` /\n * `AdaptiveGroup`). Separate from `__sentient_overrides` (variant components):\n * a slot result is a token object (`{ tone: 'urgent' }`) or an arm string\n * (`'social_first'`), never a bare variant id. Window-backed so the /devtools\n * bundle and the main bundle share one store.\n */\nfunction store(): Record<string, SlotResult> {\n const w = window as unknown as { __sentient_slot_overrides?: Record<string, SlotResult> };\n if (!w.__sentient_slot_overrides) w.__sentient_slot_overrides = {};\n return w.__sentient_slot_overrides;\n}\n\n/** Force `slotId` to resolve to `result` — read by `useSlotResult`. */\nexport function setSlotOverride(slotId: string, result: SlotResult): void {\n store()[slotId] = result;\n}\n\nexport function clearSlotOverride(slotId: string): void {\n delete store()[slotId];\n}\n\nexport function getSlotOverrides(): Record<string, SlotResult> {\n return { ...store() };\n}\n","import type { SentientClient } from '@sentientui/core';\n\ntype PreviewState = { on: boolean; listeners: Set<() => void> };\nconst ssrFallback: PreviewState = { on: false, listeners: new Set() };\n\n// Window-backed: the /devtools entry (a separate bundle) toggles preview mode\n// and the provider (main bundle) must observe it.\nfunction state(): PreviewState {\n if (typeof window === 'undefined') return ssrFallback;\n const w = window as unknown as { __sentient_preview?: PreviewState };\n if (!w.__sentient_preview) w.__sentient_preview = { on: false, listeners: new Set() };\n return w.__sentient_preview;\n}\n\nexport function setPreviewMode(on: boolean): void {\n const s = state();\n if (s.on === on) return;\n s.on = on;\n for (const fn of s.listeners) fn();\n}\n\nexport function getPreviewMode(): boolean {\n return state().on;\n}\n\nexport function subscribePreview(fn: () => void): () => void {\n const listeners = state().listeners;\n listeners.add(fn);\n return () => {\n listeners.delete(fn);\n };\n}\n\n/**\n * Wraps a client so it writes nothing: reads pass through, all emitters no-op.\n * Used while previewing variants/personas so no `variant_assigned`, goal, or\n * session events are sent.\n */\nexport function createPreviewClient(inner: SentientClient): SentientClient {\n return {\n isLocal: inner.isLocal,\n track: () => undefined,\n goal: () => undefined,\n componentGoal: () => undefined,\n identify: () => undefined,\n fetchWeights: () => Promise.resolve([]),\n getAssignment: (componentId, segment) => inner.getAssignment(componentId, segment),\n assign: (componentId, variantIds, agentData, agentDataByVariant) =>\n inner.assign(componentId, variantIds, agentData, agentDataByVariant),\n // Reads pass through; decide is a write (slot decisions persist server-side)\n // so preview mode never issues it.\n decide: () => Promise.resolve(null),\n getSlotResult: (slotId) => inner.getSlotResult(slotId),\n getSlotConfig: (slotId) => inner.getSlotConfig(slotId),\n getSitePalette: () => inner.getSitePalette(),\n reportSlots: (ids) => inner.reportSlots(ids),\n getPersona: () => inner.getPersona(),\n getGraph: () => inner.getGraph(),\n flush: () => inner.flush(),\n dispose: () => inner.dispose(),\n destroy: () => inner.destroy(),\n };\n}\n","/**\n * Cross-bundle re-render bus for devtools overrides. The main entry and the\n * /devtools entry are separate bundles, so state and notifications go through\n * window (a version counter + a DOM event) — never module-local state.\n */\nconst EVENT = 'sentient:overrides-changed';\n\ntype VersionWindow = Window & { __sentient_overrides_version?: number };\n\nexport function getOverridesVersion(): number {\n if (typeof window === 'undefined') return 0;\n return (window as VersionWindow).__sentient_overrides_version ?? 0;\n}\n\nexport function notifyOverridesChanged(): void {\n if (typeof window === 'undefined') return;\n const w = window as VersionWindow;\n w.__sentient_overrides_version = (w.__sentient_overrides_version ?? 0) + 1;\n window.dispatchEvent(new Event(EVENT));\n}\n\nexport function subscribeOverridesChanged(fn: () => void): () => void {\n if (typeof window === 'undefined') return () => undefined;\n window.addEventListener(EVENT, fn);\n return () => window.removeEventListener(EVENT, fn);\n}\n","/** Provider → devtools config handoff. Window-backed: the /devtools entry is a\n * separate bundle and cannot share the provider's React context instance. */\nexport type DevtoolsConfig = {\n apiKey: string;\n apiBaseUrl: string;\n isLocal: boolean;\n};\n\ntype ConfigWindow = Window & { __sentient_devtools_config?: DevtoolsConfig };\n\nexport function publishDevtoolsConfig(config: DevtoolsConfig): void {\n if (typeof window === 'undefined') return;\n (window as ConfigWindow).__sentient_devtools_config = config;\n}\n\nexport function readDevtoolsConfig(): DevtoolsConfig | null {\n if (typeof window === 'undefined') return null;\n return (window as ConfigWindow).__sentient_devtools_config ?? null;\n}\n"],"mappings":";ocAGA,OAAS,aAAAA,GAAW,cAAAC,GAAY,YAAAC,EAAU,wBAAAC,OAA0D,QACpG,OAAS,mBAAAC,GAAiB,2BAAAC,GAAyB,kBAAAC,GAAgB,4BAAAC,OAAgC,qBACnG,OAAS,8BAAAC,GAA4B,+BAAAC,GAA6B,qBAAAC,OAAyB,mBCgB3F,IAAMC,GAA6B,CACjC,WAAY,IAAI,IAChB,MAAO,IAAI,IACX,SAAU,CAAC,EACX,UAAW,IAAI,IACf,QAAS,CACX,EAEA,SAASC,GAAuB,CAC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B,EAAE,EAgCZ,CAEJ,CAAC,GACH,GAEJ,EACF,EACArC,EAAC,UACC,aAAW,oBACX,gBAAeyE,EACf,QAAS,IAAMC,EAAS0D,GAAM,CAACA,CAAC,EAChC,MAAO,CAAE,MAAO,GAAI,OAAQ,GAAI,aAAc,GAAI,OAAQ,oBAAqB,WAAY,OAClF,QAAS,OAAQ,WAAY,SAAU,eAAgB,SAAU,QAAS,EAC1E,OAAQ,UAAW,UAAW,2BAA4B,EAEnE,SAAApI,EAACsE,GAAA,EAAa,EAChB,GACF,CAEJ","names":["useEffect","useReducer","useState","useSyncExternalStore","UNKNOWN_PERSONA","UNKNOWN_PERSONA_DISPLAY","confidenceBand","normalizeDeclaredPersona","LEGACY_SESSION_COOKIE_NAME","SNAPSHOT_STORAGE_KEY_PREFIX","sessionCookieName","ssrFallback","state","w","getRegistered","state","getRegisteredSlots","getRegisteredSections","subscribeRegistry","fn","listeners","getRegistryVersion","store","w","setVariantOverride","componentId","variantId","clearVariantOverride","getOverrides","__spreadValues","store","w","setSlotOverride","slotId","result","clearSlotOverride","getSlotOverrides","__spreadValues","ssrFallback","state","w","setPreviewMode","on","s","fn","getPreviewMode","EVENT","notifyOverridesChanged","_a","w","EVENT","readDevtoolsConfig","_a","jsx","jsxs","_a","IS_PROD","DEFAULT_API_BASE_URL","LOCAL_MODE_DEVTOOLS_BANNER","currentLayout","forced","registered","getRegisteredSections","id","reorderLayout","from","to","order","next","moved","setPreviewMode","notifyOverridesChanged","resetLayout","applyOutcome","result","_b","variantId","setVariantOverride","w","__spreadValues","readSessionId","apiKey","read","name","match","e","sessionCookieName","LEGACY_SESSION_COOKIE_NAME","slotDecls","getRegisteredSlots","s","UNKNOWN_CHOICE","UNKNOWN_PERSONA","UNKNOWN_PERSONA_DISPLAY","fetchPersonaVocabulary","apiBaseUrl","res","data","valid","list","p","personas","previewContextParam","v","forcePersonaKeyed","persona","_c","getRegistered","c","__spreadProps","forcePersonaLocal","mod","outcome","confidenceBand","resetAll","getOverrides","clearVariantOverride","stale","i","key","SNAPSHOT_STORAGE_KEY_PREFIX","btn","active","SentientMark","size","AdaptiveDevtools","open","setOpen","useState","activePersona","setActivePersona","vocab","setVocab","customKey","setCustomKey","discovered","setDiscovered","personaNote","setPersonaNote","dragFrom","setDragFrom","mounted","setMounted","force","useReducer","n","useSyncExternalStore","subscribeRegistry","getRegistryVersion","useEffect","cfg","readDevtoolsConfig","cancelled","config","useLocalEngine","components","slots","overrides","slotOverrides","getSlotOverrides","sections","layoutForced","onReorder","onResetLayout","maybeExitPreview","choose","resetVariant","chooseSlotArm","arm","setSlotOverride","chooseSlotDim","dim","value","dims","current","d","values","resetSlot","clearSlotOverride","choosePersona","member","r","getPreviewMode","normalizeDeclaredPersona","ov","o"]}
1
+ {"version":3,"sources":["../src/devtools/index.tsx","../src/devtools-registry.ts","../src/devtools-overrides.ts","../src/devtools-slot-overrides.ts","../src/preview-mode.ts","../src/override-events.ts","../src/devtools-config.ts"],"sourcesContent":["'use client';\n// `type JSX` from react, not the global namespace removed in @types/react@19\n// (peers allow react >=18) — see adaptive-text.tsx.\nimport { useEffect, useReducer, useState, useSyncExternalStore, type CSSProperties, type JSX } from 'react';\nimport { UNKNOWN_PERSONA, UNKNOWN_PERSONA_DISPLAY, confidenceBand, normalizeDeclaredPersona } from '@sentientui/policy';\nimport { LEGACY_SESSION_COOKIE_NAME, SNAPSHOT_STORAGE_KEY_PREFIX, sessionCookieName } from '@sentientui/core';\nimport {\n getRegistered,\n getRegisteredSlots,\n getRegisteredSections,\n subscribeRegistry,\n getRegistryVersion,\n type RegisteredSlot,\n} from '../devtools-registry.js';\nimport { setVariantOverride, clearVariantOverride, getOverrides } from '../devtools-overrides.js';\nimport { setSlotOverride, clearSlotOverride, getSlotOverrides } from '../devtools-slot-overrides.js';\nimport { setPreviewMode, getPreviewMode } from '../preview-mode.js';\nimport { notifyOverridesChanged } from '../override-events.js';\nimport { readDevtoolsConfig, type DevtoolsConfig } from '../devtools-config.js';\n\ndeclare const process: { env?: { NODE_ENV?: string } } | undefined;\nconst IS_PROD = typeof process !== 'undefined' && process.env?.NODE_ENV === 'production';\nconst DEFAULT_API_BASE_URL = 'https://api.sentient-ui.com/v1';\n\nexport const LOCAL_MODE_DEVTOOLS_BANNER =\n 'Local mode — decisions are simulated; add a key to learn from real traffic';\n\ntype OutcomeToApply = {\n assignments?: Record<string, string>;\n layoutOrder?: string[] | null;\n slots?: Record<string, string | Record<string, string>>;\n personaAttributes?: { persona: string; confidence: 'low' | 'medium' | 'high' };\n};\n\ntype OverrideWindow = Window & {\n __sentient_layout_override?: string[];\n __sentient_slot_overrides?: Record<string, string | Record<string, string>>;\n};\n\n/** The order the page is rendering: a previewed override, else what was registered. */\nfunction currentLayout(): string[] {\n const forced = (window as unknown as OverrideWindow).__sentient_layout_override;\n const registered = getRegisteredSections();\n if (!forced || forced.length === 0) return registered;\n // Registered ids the override omits still render (useLayoutOrder returns the\n // override verbatim, and the app maps whatever ids it is given), so show them\n // trailing rather than dropping them from the list you are dragging.\n return [...forced, ...registered.filter((id) => !forced.includes(id))];\n}\n\n/**\n * Move `from` to `to` within the current order and preview it.\n *\n * Writes the whole order rather than swapping neighbours: the point is to try an\n * arrangement, not to walk one block up a list one press at a time.\n */\nfunction reorderLayout(from: number, to: number): void {\n const order = currentLayout();\n if (from === to || from < 0 || to < 0 || from >= order.length || to >= order.length) return;\n const next = [...order];\n const [moved] = next.splice(from, 1);\n next.splice(to, 0, moved!);\n (window as unknown as OverrideWindow).__sentient_layout_override = next;\n setPreviewMode(true); // an arrangement you are trying must not train the bandit\n notifyOverridesChanged();\n}\n\nfunction resetLayout(): void {\n delete (window as unknown as OverrideWindow).__sentient_layout_override;\n notifyOverridesChanged();\n}\n\n/** Apply a simulated outcome across every surface: variants, layout, slots/tokens, persona attrs. */\nfunction applyOutcome(result: OutcomeToApply): void {\n for (const [id, variantId] of Object.entries(result.assignments ?? {})) {\n setVariantOverride(id, variantId);\n }\n const w = window as unknown as OverrideWindow;\n if (result.layoutOrder && result.layoutOrder.length > 0) {\n w.__sentient_layout_override = result.layoutOrder;\n }\n if (result.slots) {\n w.__sentient_slot_overrides = { ...(w.__sentient_slot_overrides ?? {}), ...result.slots };\n }\n if (result.personaAttributes) {\n document.documentElement.dataset.sentientPersona = result.personaAttributes.persona;\n document.documentElement.dataset.sentientConfidence = result.personaAttributes.confidence;\n }\n setPreviewMode(true); // suppress events while previewing\n notifyOverridesChanged(); // re-render layout/slot consumers\n}\n\n// Reads the SDK's own session cookie — the per-project SUFFIXED name first\n// (that is what the client writes since namespacing; the bare `_snt_uid` this\n// used to read is only written in keyless/local mode), then the bare name as\n// the legacy/local fallback.\nfunction readSessionId(apiKey?: string): string {\n const read = (name: string): string | null => {\n try {\n const match = document.cookie.match(new RegExp(`(?:^|; )${name}=([^;]*)`));\n return match ? decodeURIComponent(match[1]!) : null;\n } catch {\n return null;\n }\n };\n return (apiKey ? read(sessionCookieName(apiKey)) : null) ?? read(LEGACY_SESSION_COOKIE_NAME) ?? 'devtools-preview';\n}\n\nfunction slotDecls(): Array<{ id: string; arms?: string[]; dims?: RegisteredSlot['dims'] }> {\n return getRegisteredSlots().map((s) => ({\n id: s.id,\n ...(s.arms ? { arms: s.arms } : {}),\n ...(s.dims ? { dims: s.dims } : {}),\n }));\n}\n\n/** One member of the project's persona vocabulary, as /v1/personas serves it. */\ntype VocabMember = { key: string; displayName: string };\n\n/** Always offered: previewing the unidentified visitor is meaningful on every\n * project, and it is the only persona the product itself defines. */\nconst UNKNOWN_CHOICE: VocabMember = { key: UNKNOWN_PERSONA, displayName: UNKNOWN_PERSONA_DISPLAY };\n\n/**\n * Keyed mode: the project's ACTIVE vocabulary from /v1/personas. Personas are\n * per-project (persona_sets, migration 113) — declared by the app or promoted\n * by discovery. This used to fall back to a hardcoded list of four seeded\n * personas, which offered buttons that silently simulated the default\n * experience on any project whose vocabulary differs, and named audiences\n * nobody had declared. null on any failure → the panel offers only `unknown`\n * and a free-text key.\n */\nasync function fetchPersonaVocabulary(\n apiKey: string,\n apiBaseUrl: string,\n): Promise<{ personas: VocabMember[]; discovered: VocabMember[] } | null> {\n try {\n const res = await fetch(`${apiBaseUrl}/personas`, {\n headers: { authorization: `Bearer ${apiKey}` },\n });\n if (!res.ok) return null;\n const data = (await res.json()) as { personas?: VocabMember[]; discovered?: VocabMember[] };\n const valid = (list: VocabMember[] | undefined): VocabMember[] =>\n Array.isArray(list)\n ? list.filter((p) => p && typeof p.key === 'string' && typeof p.displayName === 'string')\n : [];\n const personas = valid(data.personas);\n return personas.length > 0 ? { personas, discovered: valid(data.discovered) } : null;\n } catch {\n return null;\n }\n}\n\n/**\n * `?sentient_context=<context>` on the page URL: the on-site context preview\n * (a stage such as `carted`, or an arrival class such as `cart_recovery`).\n * Forwarded to /v1/explain so a persona simulated from this panel is also\n * simulated in that context — the API validates the value (400 on anything\n * else) and applies it to the project's published (registry) versions:\n * those restricted to the context become eligible and its pins win. Lives\n * here, not in the provider: devtools is the React SDK's only explain-backed\n * preview, and the main bundle pays for nothing it does not use.\n * @internal Exported for tests.\n */\nexport function previewContextParam(): string | null {\n try {\n const v = new URLSearchParams(window.location.search).get('sentient_context');\n return v && /^[a-z_]{1,40}$/.test(v) ? v : null;\n } catch {\n return null;\n }\n}\n\n/** Keyed mode: simulate via /v1/explain (read-only, event-free). Returns how\n * the persona RESOLVED so the panel can say when the project didn't\n * recognize it — the page then shows the default experience, and a silently\n * highlighted button claiming otherwise was the old lie. */\nasync function forcePersonaKeyed(\n apiKey: string,\n apiBaseUrl: string,\n persona: string,\n): Promise<{ recognized: boolean; resolvedDisplay: string } | null> {\n const res = await fetch(`${apiBaseUrl}/explain`, {\n method: 'POST',\n headers: { 'content-type': 'application/json', authorization: `Bearer ${apiKey}` },\n body: JSON.stringify({\n persona,\n sections: getRegisteredSections().map((id) => ({ id })),\n components: getRegistered().map((c) => ({ id: c.id, variantIds: c.variantIds })),\n slots: slotDecls(),\n ...(previewContextParam() ? { context: previewContextParam() } : {}),\n }),\n });\n if (!res.ok) return null;\n const data = (await res.json()) as OutcomeToApply & {\n recognized?: boolean;\n persona?: string;\n personaDisplay?: string;\n };\n applyOutcome({\n ...data,\n personaAttributes: data.personaAttributes ?? { persona, confidence: 'high' },\n });\n return {\n // An older API omits the field — treat as recognized (no basis to warn).\n recognized: data.recognized !== false,\n resolvedDisplay: data.personaDisplay ?? data.persona ?? persona,\n };\n}\n\n/** Local mode: simulate via the deterministic local engine — zero network. */\nasync function forcePersonaLocal(persona: string, apiKey?: string): Promise<void> {\n const mod = await import('@sentientui/core/local');\n if (!mod.LOCAL_ENGINE_AVAILABLE) return;\n const outcome = mod\n .createLocalEngine({ sessionId: readSessionId(apiKey), forcedPersona: persona })\n .decide({\n sections: getRegisteredSections(),\n components: getRegistered().map((c) => ({ id: c.id, variantIds: c.variantIds })),\n slots: slotDecls(),\n });\n applyOutcome({\n assignments: outcome.assignments,\n layoutOrder: outcome.layoutOrder,\n slots: outcome.slots,\n personaAttributes: {\n persona: outcome.persona,\n confidence: confidenceBand(outcome.confidence),\n },\n });\n}\n\n/** Reset: clear the decision snapshot + every override, then reload to re-decide. */\nfunction resetAll(): void {\n for (const id of Object.keys(getOverrides())) clearVariantOverride(id);\n const w = window as unknown as OverrideWindow;\n delete w.__sentient_layout_override;\n delete w.__sentient_slot_overrides;\n delete document.documentElement.dataset.sentientPersona;\n delete document.documentElement.dataset.sentientConfidence;\n try {\n const stale: string[] = [];\n for (let i = 0; i < localStorage.length; i++) {\n const key = localStorage.key(i);\n if (key && key.startsWith(SNAPSHOT_STORAGE_KEY_PREFIX)) stale.push(key);\n }\n for (const key of stale) localStorage.removeItem(key);\n } catch {\n /* ignore */\n }\n setPreviewMode(false);\n notifyOverridesChanged();\n try {\n window.location.reload();\n } catch {\n /* jsdom */\n }\n}\n\nconst btn = (active: boolean): CSSProperties => ({\n padding: '2px 8px',\n borderRadius: 4,\n border: '1px solid #444',\n background: active ? '#3b82f6' : '#222',\n color: '#eee',\n cursor: 'pointer',\n});\n\n/** Sentient \"S.\" wordmark, monoline — white strokes for the black launcher button. */\nfunction SentientMark({ size = 26 }: { size?: number } = {}): JSX.Element {\n return (\n <svg width={size} height={size} viewBox=\"0 0 32 32\" fill=\"none\" aria-hidden=\"true\">\n <path\n d=\"M21 9H14C11.2 9 9.8 10.8 9.8 13C9.8 15.4 11.6 16.6 14.5 16.6H18.5C20.5 16.6 20.7 18.2 20.4 19.6\"\n stroke=\"#fff\"\n strokeWidth=\"2.2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n <path d=\"M10 22H17\" stroke=\"#fff\" strokeWidth=\"2.2\" strokeLinecap=\"round\" />\n <circle cx=\"20.6\" cy=\"22\" r=\"2.1\" fill=\"#fff\" />\n </svg>\n );\n}\n\nexport function AdaptiveDevtools({ apiKey }: { apiKey?: string } = {}): JSX.Element | null {\n const [open, setOpen] = useState(false);\n const [activePersona, setActivePersona] = useState<string | null>(null);\n // The project's vocabulary (keyed mode); null = not loaded → no persona\n // buttons beyond `unknown`. Local mode never fetches: there is no project,\n // and the local engine previews ANY key typed into the free-text field.\n const [vocab, setVocab] = useState<VocabMember[] | null>(null);\n const [customKey, setCustomKey] = useState('');\n // Discovered SHADOW personas — display-only. They never serve until\n // promotion, so there is no button: forcing one would simulate a persona\n // that cannot occur on this project.\n const [discovered, setDiscovered] = useState<VocabMember[]>([]);\n // Set when a forced persona did NOT resolve against the project's\n // vocabulary — the page is showing the default experience and the panel\n // must say so instead of highlighting the button as if the preview worked.\n const [personaNote, setPersonaNote] = useState<string | null>(null);\n const [dragFrom, setDragFrom] = useState<number | null>(null);\n const [mounted, setMounted] = useState(false);\n const [, force] = useReducer((n: number) => n + 1, 0);\n // Re-render when the component/slot registry changes. useSyncExternalStore\n // (not a manual useEffect subscription) so the subscription can't go stale\n // across Next Fast Refresh — a stale listener was why the panel needed a hard\n // refresh to pick up a renamed id.\n useSyncExternalStore(subscribeRegistry, getRegistryVersion, () => 0);\n // Client-mount gate: render nothing during SSR / the first paint so the widget\n // never reads `window` on the server. Lets consumers drop `<AdaptiveDevtools/>`\n // straight into a tree without a `dynamic(..., { ssr: false })` wrapper.\n useEffect(() => setMounted(true), []);\n // Load the project's persona vocabulary once (keyed mode only).\n useEffect(() => {\n if (IS_PROD) return;\n const cfg = readDevtoolsConfig() ?? { apiKey: apiKey ?? '', apiBaseUrl: DEFAULT_API_BASE_URL, isLocal: false };\n if (cfg.isLocal || !cfg.apiKey) return;\n let cancelled = false;\n void fetchPersonaVocabulary(cfg.apiKey, cfg.apiBaseUrl).then((v) => {\n if (cancelled || !v) return;\n setVocab(v.personas);\n setDiscovered(v.discovered);\n });\n return () => { cancelled = true; };\n }, [apiKey]);\n\n // Never render in production, even if imported by mistake. (Hooks run first\n // so the rules of hooks hold regardless of these early returns.)\n if (IS_PROD) return null;\n if (!mounted) return null;\n\n const config: DevtoolsConfig = readDevtoolsConfig() ?? {\n apiKey: apiKey ?? '',\n apiBaseUrl: DEFAULT_API_BASE_URL,\n isLocal: false,\n };\n const useLocalEngine = config.isLocal || !config.apiKey;\n const components = getRegistered();\n const slots = getRegisteredSlots();\n const overrides = getOverrides();\n const slotOverrides = getSlotOverrides();\n const sections = currentLayout();\n const layoutForced = (window as unknown as OverrideWindow).__sentient_layout_override !== undefined;\n\n function onReorder(from: number, to: number): void {\n reorderLayout(from, to);\n force();\n }\n function onResetLayout(): void {\n resetLayout();\n maybeExitPreview();\n force();\n }\n\n // Preview mode stays on while ANY override (variant, slot or layout) is\n // active. Omitting layout here let clearing the last variant re-enable event\n // recording while a previewed section order was still on screen.\n function maybeExitPreview(): void {\n if (\n Object.keys(getOverrides()).length === 0 &&\n Object.keys(getSlotOverrides()).length === 0 &&\n (window as unknown as OverrideWindow).__sentient_layout_override === undefined\n ) {\n setPreviewMode(false);\n }\n }\n\n function choose(id: string, variantId: string): void {\n setVariantOverride(id, variantId);\n setPreviewMode(true);\n notifyOverridesChanged();\n force();\n }\n function resetVariant(id: string): void {\n clearVariantOverride(id);\n maybeExitPreview();\n notifyOverridesChanged();\n force();\n }\n function chooseSlotArm(id: string, arm: string): void {\n setSlotOverride(id, arm);\n setPreviewMode(true);\n notifyOverridesChanged();\n force();\n }\n function chooseSlotDim(id: string, dim: string, value: string, dims: RegisteredSlot['dims']): void {\n const current = getSlotOverrides()[id];\n // Merge onto the existing forced object, or seed from each dim's baseline\n // (first value) so unset dims stay at baseline instead of vanishing.\n const next: Record<string, string> =\n current && typeof current === 'object'\n ? { ...current }\n : Object.fromEntries(Object.entries(dims ?? {}).map(([d, values]) => [d, values[0]!]));\n next[dim] = value;\n setSlotOverride(id, next);\n setPreviewMode(true);\n notifyOverridesChanged();\n force();\n }\n function resetSlot(id: string): void {\n clearSlotOverride(id);\n maybeExitPreview();\n notifyOverridesChanged();\n force();\n }\n function choosePersona(member: VocabMember): void {\n setActivePersona(member.key);\n setPersonaNote(null);\n // .catch: a failed simulate (offline /v1/explain, bad key, failed local\n // dynamic import) is a preview no-op — without the handler it surfaced as\n // an unhandled promise rejection in the console.\n if (useLocalEngine) {\n forcePersonaLocal(member.key, config.apiKey).then(force).catch(() => {});\n return;\n }\n forcePersonaKeyed(config.apiKey, config.apiBaseUrl, member.key)\n .then((r) => {\n if (r && !r.recognized) {\n setPersonaNote(\n `“${member.displayName}” isn’t in this project’s personas — the page is showing the default experience.`,\n );\n }\n force();\n })\n .catch(() => {});\n }\n\n return (\n <div style={{ position: 'fixed', bottom: 16, right: 16, zIndex: 2147483647, fontFamily: 'system-ui' }}>\n {/* Panel stays mounted and animates in/out from the button's corner, so the\n launcher below never shifts. transform-origin is the button (bottom-right). */}\n <div\n aria-hidden={!open}\n style={{\n position: 'absolute',\n bottom: 52,\n right: 0,\n transformOrigin: 'bottom right',\n transition: 'opacity .18s ease, transform .2s cubic-bezier(.16,1,.3,1)',\n opacity: open ? 1 : 0,\n transform: open ? 'translateY(0) scale(1)' : 'translateY(6px) scale(.96)',\n pointerEvents: open ? 'auto' : 'none',\n }}\n >\n <div style={{ width: 300, maxHeight: 460, overflowY: 'auto', background: '#111', color: '#eee',\n borderRadius: 8, padding: 12, boxShadow: '0 8px 30px rgba(0,0,0,.4)', fontSize: 12 }}>\n {config.isLocal && (\n <div style={{ background: '#1e293b', border: '1px solid #334155', borderRadius: 4,\n padding: '6px 8px', marginBottom: 8 }}>\n {LOCAL_MODE_DEVTOOLS_BANNER}\n </div>\n )}\n <div style={{ opacity: .7, marginBottom: 8 }}>\n {components.length} component{components.length === 1 ? '' : 's'} · {getPreviewMode() ? 'preview — writing nothing' : 'live'}\n </div>\n <div style={{ borderBottom: '1px solid #333', paddingBottom: 8, marginBottom: 8 }}>\n <div style={{ opacity: .7, marginBottom: 4 }}>Preview persona</div>\n <div style={{ display: 'flex', flexWrap: 'wrap', gap: 4 }}>\n {/* Keyed mode renders the project's OWN vocabulary once\n /v1/personas answers; nothing is invented while it hasn't. */}\n {[...(useLocalEngine ? [] : vocab ?? []), UNKNOWN_CHOICE].map((p) => (\n <button key={p.key} onClick={() => choosePersona(p)} style={btn(activePersona === p.key)}>\n {p.displayName}\n </button>\n ))}\n {(activePersona !== null || Object.keys(overrides).length > 0 || Object.keys(slotOverrides).length > 0) && (\n <button onClick={resetAll} style={{ ...btn(false), color: '#aaa' }}>\n Reset\n </button>\n )}\n </div>\n <form\n onSubmit={(e) => {\n e.preventDefault();\n const key = normalizeDeclaredPersona(customKey);\n if (key) choosePersona({ key, displayName: key });\n }}\n style={{ display: 'flex', gap: 4, marginTop: 6 }}\n >\n <input\n aria-label=\"Persona key\"\n placeholder=\"any persona key, e.g. admin\"\n value={customKey}\n onChange={(e) => setCustomKey(e.target.value)}\n style={{ flex: 1, minWidth: 0, background: '#111', color: '#fff', border: '1px solid #333',\n borderRadius: 4, padding: '4px 6px', fontSize: 12 }}\n />\n <button type=\"submit\" style={btn(false)}>Preview</button>\n </form>\n {personaNote && (\n <div style={{ marginTop: 6, fontSize: 11, color: '#fbbf24' }}>{personaNote}</div>\n )}\n {!useLocalEngine && discovered.length > 0 && (\n <div style={{ marginTop: 8 }}>\n <div style={{ opacity: .5, fontSize: 11, marginBottom: 4 }}>\n Discovered — not serving yet (promote from the dashboard)\n </div>\n <div style={{ display: 'flex', flexWrap: 'wrap', gap: 4 }}>\n {discovered.map((p) => (\n <span\n key={p.key}\n title=\"Found by clustering your traffic; it starts serving only after promotion.\"\n style={{ ...btn(false), opacity: .45, cursor: 'default', display: 'inline-block' }}\n >\n {p.displayName}\n </span>\n ))}\n </div>\n </div>\n )}\n </div>\n {sections.length > 0 && (\n <div style={{ borderBottom: '1px solid #333', paddingBottom: 8, marginBottom: 8 }}>\n <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', marginBottom: 4 }}>\n <span style={{ opacity: .7 }}>Layout — drag to reorder</span>\n {layoutForced && (\n // Distinct accessible name: the per-variant and per-slot resets\n // below are also labelled \"reset\", and three identical buttons\n // in one panel is ambiguous to a screen reader and to tests.\n <button\n aria-label=\"Reset section order\"\n onClick={onResetLayout}\n style={{ ...btn(false), color: '#aaa' }}\n >\n reset\n </button>\n )}\n </div>\n {/* Drop-on-row inserts at that row's position, so any block can go\n anywhere in one gesture. The whole order is written on each\n drop — see reorderLayout. */}\n <ul aria-label=\"Section order\" style={{ listStyle: 'none', margin: 0, padding: 0 }}>\n {sections.map((id, i) => (\n <li\n key={id}\n draggable\n onDragStart={() => setDragFrom(i)}\n onDragOver={(e) => e.preventDefault()}\n onDrop={(e) => {\n e.preventDefault();\n if (dragFrom !== null) onReorder(dragFrom, i);\n setDragFrom(null);\n }}\n onDragEnd={() => setDragFrom(null)}\n style={{\n display: 'flex', alignItems: 'center', gap: 6, padding: '4px 6px', marginBottom: 2,\n borderRadius: 4, border: '1px solid #262626', cursor: 'grab',\n background: dragFrom === i ? '#1e293b' : '#181818',\n opacity: dragFrom !== null && dragFrom !== i ? .6 : 1,\n }}\n >\n <span style={{ opacity: .4, minWidth: 10, fontVariantNumeric: 'tabular-nums' }}>{i + 1}</span>\n <span aria-hidden=\"true\" style={{ opacity: .35 }}>⠿</span>\n <span style={{ flex: 1, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>\n {id}\n </span>\n </li>\n ))}\n </ul>\n </div>\n )}\n {components.length === 0 && slots.length === 0 && sections.length === 0 && (\n <div style={{ opacity: .6 }}>No components, sections or slots on this page yet.</div>\n )}\n {components.map((c) => (\n <div key={c.id} style={{ borderTop: '1px solid #333', padding: '8px 0' }}>\n <div style={{ fontWeight: 600 }}>{c.id}{c.goal ? ` · goal: ${c.goal}` : ''}</div>\n <div style={{ display: 'flex', flexWrap: 'wrap', gap: 4, marginTop: 4 }}>\n {c.variantIds.map((v) => (\n <button key={v} onClick={() => choose(c.id, v)} style={btn(overrides[c.id] === v)}>\n {v}\n </button>\n ))}\n {overrides[c.id] && (\n <button onClick={() => resetVariant(c.id)} style={{ ...btn(false), color: '#aaa' }}>\n reset\n </button>\n )}\n </div>\n </div>\n ))}\n {slots.length > 0 && (\n <div style={{ borderTop: '1px solid #333', paddingTop: 8, marginTop: 4 }}>\n <div style={{ opacity: .7, marginBottom: 4 }}>Slots</div>\n {slots.map((s) => {\n const ov = slotOverrides[s.id];\n return (\n <div key={s.id} style={{ padding: '6px 0' }}>\n <div style={{ fontWeight: 600 }}>{s.id}</div>\n {s.arms && (\n <div style={{ display: 'flex', flexWrap: 'wrap', gap: 4, marginTop: 4 }}>\n {s.arms.map((arm) => (\n <button key={arm} onClick={() => chooseSlotArm(s.id, arm)} style={btn(ov === arm)}>\n {arm}\n </button>\n ))}\n </div>\n )}\n {s.dims && Object.entries(s.dims).map(([dim, values]) => (\n <div key={dim} style={{ marginTop: 4 }}>\n <div style={{ opacity: .6, fontSize: 11 }}>{dim}</div>\n <div style={{ display: 'flex', flexWrap: 'wrap', gap: 4 }}>\n {values.map((v) => (\n <button\n key={v}\n onClick={() => chooseSlotDim(s.id, dim, v, s.dims)}\n style={btn(!!ov && typeof ov === 'object' && ov[dim] === v)}\n >\n {v}\n </button>\n ))}\n </div>\n </div>\n ))}\n {ov !== undefined && (\n <button onClick={() => resetSlot(s.id)} style={{ ...btn(false), color: '#aaa', marginTop: 4 }}>\n reset\n </button>\n )}\n </div>\n );\n })}\n </div>\n )}\n </div>\n </div>\n <button\n aria-label=\"Sentient DevTools\"\n aria-expanded={open}\n onClick={() => setOpen((o) => !o)}\n style={{ width: 44, height: 44, borderRadius: 12, border: '1px solid #2a2a2a', background: '#000',\n display: 'flex', alignItems: 'center', justifyContent: 'center', padding: 0,\n cursor: 'pointer', boxShadow: '0 6px 18px rgba(0,0,0,.4)' }}\n >\n <SentientMark />\n </button>\n </div>\n );\n}\n","import { isDevBuild } from './adaptive-shared.js';\n\nexport type RegisteredComponent = { id: string; variantIds: string[]; goal?: string };\nexport type RegisteredSlot = {\n id: string;\n arms?: string[];\n dims?: Record<string, readonly string[]>;\n};\n\ntype RegistryState = {\n components: Map<string, RegisteredComponent>;\n slots: Map<string, RegisteredSlot>;\n sections: string[];\n listeners: Set<() => void>;\n /** Bumped on every mutation so `useSyncExternalStore` can read a stable, comparable snapshot. */\n version: number;\n};\n\n// Shared through a window global: the main entry and the /devtools entry are\n// separate bundles, each with its own copy of this module — module-local\n// state would give the devtools an always-empty registry in published apps.\nconst ssrFallback: RegistryState = {\n components: new Map(),\n slots: new Map(),\n sections: [],\n listeners: new Set(),\n version: 0,\n};\n\nfunction state(): RegistryState {\n if (typeof window === 'undefined') return ssrFallback;\n const w = window as unknown as { __sentient_registry?: RegistryState };\n if (!w.__sentient_registry) {\n w.__sentient_registry = {\n components: new Map(),\n slots: new Map(),\n sections: [],\n listeners: new Set(),\n version: 0,\n };\n }\n return w.__sentient_registry;\n}\n\nfunction emit(): void {\n // Bump BEFORE notifying so a useSyncExternalStore consumer re-reading its\n // snapshot inside the notification sees the new value and re-renders.\n state().version += 1;\n for (const fn of state().listeners) fn();\n}\n\n// The registry exists solely to feed the opt-in devtools panel, which is a\n// dev-only surface. In a production build there is no panel reading it, so\n// every register call is dead work plus a `window.__sentient_registry`\n// footprint on the customer's page. Short-circuit to a noop in production —\n// every <Adaptive>/useAdaptive/slot mount calls one of these.\nconst NOOP_UNREGISTER = (): void => undefined;\n\n/** Register (or re-register) a component. Returns an unregister function. */\nexport function registerComponent(c: RegisteredComponent): () => void {\n if (!isDevBuild()) return NOOP_UNREGISTER;\n state().components.set(c.id, c);\n emit();\n return () => {\n state().components.delete(c.id);\n emit();\n };\n}\n\n/** Register (or re-register) a slot declaration. Returns an unregister function. */\nexport function registerSlot(s: RegisteredSlot): () => void {\n if (!isDevBuild()) return NOOP_UNREGISTER;\n state().slots.set(s.id, s);\n emit();\n return () => {\n state().slots.delete(s.id);\n emit();\n };\n}\n\n/** Register the page's declared section ids (from AdaptiveRoot/provider). */\nexport function registerSections(sections: string[]): void {\n if (!isDevBuild()) return;\n state().sections = [...sections];\n emit();\n}\n\nexport function getRegistered(): RegisteredComponent[] {\n return [...state().components.values()];\n}\n\nexport function getRegisteredSlots(): RegisteredSlot[] {\n return [...state().slots.values()];\n}\n\nexport function getRegisteredSections(): string[] {\n return [...state().sections];\n}\n\nexport function subscribeRegistry(fn: () => void): () => void {\n const listeners = state().listeners;\n listeners.add(fn);\n return () => {\n listeners.delete(fn);\n };\n}\n\n/** Monotonic snapshot for `useSyncExternalStore` — changes on every registry mutation. */\nexport function getRegistryVersion(): number {\n return state().version;\n}\n","function store(): Record<string, string> {\n const w = window as unknown as { __sentient_overrides?: Record<string, string> };\n if (!w.__sentient_overrides) w.__sentient_overrides = {};\n return w.__sentient_overrides;\n}\n\n/** Force `componentId` to render `variantId` — read by `useAssignment`. */\nexport function setVariantOverride(componentId: string, variantId: string): void {\n store()[componentId] = variantId;\n}\n\nexport function clearVariantOverride(componentId: string): void {\n delete store()[componentId];\n}\n\nexport function getOverrides(): Record<string, string> {\n return { ...store() };\n}\n","import type { SlotResult } from '@sentientui/core';\n\n/**\n * Slot-override store — the channel `useSlotResult` reads (`useAdaptiveTokens` /\n * `AdaptiveGroup`). Separate from `__sentient_overrides` (variant components):\n * a slot result is a token object (`{ tone: 'urgent' }`) or an arm string\n * (`'social_first'`), never a bare variant id. Window-backed so the /devtools\n * bundle and the main bundle share one store.\n */\nfunction store(): Record<string, SlotResult> {\n const w = window as unknown as { __sentient_slot_overrides?: Record<string, SlotResult> };\n if (!w.__sentient_slot_overrides) w.__sentient_slot_overrides = {};\n return w.__sentient_slot_overrides;\n}\n\n/** Force `slotId` to resolve to `result` — read by `useSlotResult`. */\nexport function setSlotOverride(slotId: string, result: SlotResult): void {\n store()[slotId] = result;\n}\n\nexport function clearSlotOverride(slotId: string): void {\n delete store()[slotId];\n}\n\nexport function getSlotOverrides(): Record<string, SlotResult> {\n return { ...store() };\n}\n","import type { SentientClient } from '@sentientui/core';\n\ntype PreviewState = { on: boolean; listeners: Set<() => void> };\nconst ssrFallback: PreviewState = { on: false, listeners: new Set() };\n\n// Window-backed: the /devtools entry (a separate bundle) toggles preview mode\n// and the provider (main bundle) must observe it.\nfunction state(): PreviewState {\n if (typeof window === 'undefined') return ssrFallback;\n const w = window as unknown as { __sentient_preview?: PreviewState };\n if (!w.__sentient_preview) w.__sentient_preview = { on: false, listeners: new Set() };\n return w.__sentient_preview;\n}\n\nexport function setPreviewMode(on: boolean): void {\n const s = state();\n if (s.on === on) return;\n s.on = on;\n for (const fn of s.listeners) fn();\n}\n\nexport function getPreviewMode(): boolean {\n return state().on;\n}\n\nexport function subscribePreview(fn: () => void): () => void {\n const listeners = state().listeners;\n listeners.add(fn);\n return () => {\n listeners.delete(fn);\n };\n}\n\n/**\n * Wraps a client so it writes nothing: reads pass through, all emitters no-op.\n * Used while previewing variants/personas so no `variant_assigned`, goal, or\n * session events are sent.\n */\nexport function createPreviewClient(inner: SentientClient): SentientClient {\n return {\n isLocal: inner.isLocal,\n track: () => undefined,\n goal: () => undefined,\n componentGoal: () => undefined,\n identify: () => undefined,\n fetchWeights: () => Promise.resolve([]),\n getAssignment: (componentId, segment) => inner.getAssignment(componentId, segment),\n isUnified: (componentId) => inner.isUnified?.(componentId) ?? false,\n assign: (componentId, variantIds, agentData, agentDataByVariant, opts) =>\n inner.assign(componentId, variantIds, agentData, agentDataByVariant, opts),\n // Reads pass through; decide is a write (slot decisions persist server-side)\n // so preview mode never issues it.\n decide: () => Promise.resolve(null),\n getSlotResult: (slotId) => inner.getSlotResult(slotId),\n getSlotConfig: (slotId) => inner.getSlotConfig(slotId),\n getSitePalette: () => inner.getSitePalette(),\n reportSlots: (ids) => inner.reportSlots(ids),\n getPersona: () => inner.getPersona(),\n getGraph: () => inner.getGraph(),\n flush: () => inner.flush(),\n dispose: () => inner.dispose(),\n destroy: () => inner.destroy(),\n };\n}\n","/**\n * Cross-bundle re-render bus for devtools overrides. The main entry and the\n * /devtools entry are separate bundles, so state and notifications go through\n * window (a version counter + a DOM event) — never module-local state.\n */\nconst EVENT = 'sentient:overrides-changed';\n\ntype VersionWindow = Window & { __sentient_overrides_version?: number };\n\nexport function getOverridesVersion(): number {\n if (typeof window === 'undefined') return 0;\n return (window as VersionWindow).__sentient_overrides_version ?? 0;\n}\n\nexport function notifyOverridesChanged(): void {\n if (typeof window === 'undefined') return;\n const w = window as VersionWindow;\n w.__sentient_overrides_version = (w.__sentient_overrides_version ?? 0) + 1;\n window.dispatchEvent(new Event(EVENT));\n}\n\nexport function subscribeOverridesChanged(fn: () => void): () => void {\n if (typeof window === 'undefined') return () => undefined;\n window.addEventListener(EVENT, fn);\n return () => window.removeEventListener(EVENT, fn);\n}\n","/** Provider → devtools config handoff. Window-backed: the /devtools entry is a\n * separate bundle and cannot share the provider's React context instance. */\nexport type DevtoolsConfig = {\n apiKey: string;\n apiBaseUrl: string;\n isLocal: boolean;\n};\n\ntype ConfigWindow = Window & { __sentient_devtools_config?: DevtoolsConfig };\n\nexport function publishDevtoolsConfig(config: DevtoolsConfig): void {\n if (typeof window === 'undefined') return;\n (window as ConfigWindow).__sentient_devtools_config = config;\n}\n\nexport function readDevtoolsConfig(): DevtoolsConfig | null {\n if (typeof window === 'undefined') return null;\n return (window as ConfigWindow).__sentient_devtools_config ?? null;\n}\n"],"mappings":";ocAGA,OAAS,aAAAA,GAAW,cAAAC,GAAY,YAAAC,EAAU,wBAAAC,OAA0D,QACpG,OAAS,mBAAAC,GAAiB,2BAAAC,GAAyB,kBAAAC,GAAgB,4BAAAC,OAAgC,qBACnG,OAAS,8BAAAC,GAA4B,+BAAAC,GAA6B,qBAAAC,OAAyB,mBCgB3F,IAAMC,GAA6B,CACjC,WAAY,IAAI,IAChB,MAAO,IAAI,IACX,SAAU,CAAC,EACX,UAAW,IAAI,IACf,QAAS,CACX,EAEA,SAASC,GAAuB,CAC9B,GAAI,OAAO,QAAW,YAAa,OAAOD,GAC1C,IAAME,EAAI,OACV,OAAKA,EAAE,sBACLA,EAAE,oBAAsB,CACtB,WAAY,IAAI,IAChB,MAAO,IAAI,IACX,SAAU,CAAC,EACX,UAAW,IAAI,IACf,QAAS,CACX,GAEKA,EAAE,mBACX,CA6CO,SAASC,GAAuC,CACrD,MAAO,CAAC,GAAGC,EAAM,EAAE,WAAW,OAAO,CAAC,CACxC,CAEO,SAASC,GAAuC,CACrD,MAAO,CAAC,GAAGD,EAAM,EAAE,MAAM,OAAO,CAAC,CACnC,CAEO,SAASE,GAAkC,CAChD,MAAO,CAAC,GAAGF,EAAM,EAAE,QAAQ,CAC7B,CAEO,SAASG,EAAkBC,EAA4B,CAC5D,IAAMC,EAAYL,EAAM,EAAE,UAC1B,OAAAK,EAAU,IAAID,CAAE,EACT,IAAM,CACXC,EAAU,OAAOD,CAAE,CACrB,CACF,CAGO,SAASE,IAA6B,CAC3C,OAAON,EAAM,EAAE,OACjB,CC9GA,SAASO,GAAgC,CACvC,IAAMC,EAAI,OACV,OAAKA,EAAE,uBAAsBA,EAAE,qBAAuB,CAAC,GAChDA,EAAE,oBACX,CAGO,SAASC,EAAmBC,EAAqBC,EAAyB,CAC/EJ,EAAM,EAAEG,CAAW,EAAIC,CACzB,CAEO,SAASC,EAAqBF,EAA2B,CAC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,UAEC,QAAS,IAAMqH,GAAchF,EAAE,GAAIiF,EAAKpE,EAAGb,EAAE,IAAI,EACjD,MAAO+B,EAAI,CAAC,CAAC+D,GAAM,OAAOA,GAAO,UAAYA,EAAGb,CAAG,IAAMpE,CAAC,EAEzD,SAAAA,GAJIA,CAKP,CACD,EACH,IAZQoE,CAaV,CACD,EACAa,IAAO,QACNnI,EAAC,UAAO,QAAS,IAAM4H,GAAUvF,EAAE,EAAE,EAAG,MAAOmB,EAAA9B,EAAA,GAAK0C,EAAI,EAAK,GAAd,CAAiB,MAAO,OAAQ,UAAW,CAAE,GAAG,iBAE/F,IA9BM/B,EAAE,EAgCZ,CAEJ,CAAC,GACH,GAEJ,EACF,EACArC,EAAC,UACC,aAAW,oBACX,gBAAeyE,EACf,QAAS,IAAMC,EAAS0D,GAAM,CAACA,CAAC,EAChC,MAAO,CAAE,MAAO,GAAI,OAAQ,GAAI,aAAc,GAAI,OAAQ,oBAAqB,WAAY,OAClF,QAAS,OAAQ,WAAY,SAAU,eAAgB,SAAU,QAAS,EAC1E,OAAQ,UAAW,UAAW,2BAA4B,EAEnE,SAAApI,EAACsE,GAAA,EAAa,EAChB,GACF,CAEJ","names":["useEffect","useReducer","useState","useSyncExternalStore","UNKNOWN_PERSONA","UNKNOWN_PERSONA_DISPLAY","confidenceBand","normalizeDeclaredPersona","LEGACY_SESSION_COOKIE_NAME","SNAPSHOT_STORAGE_KEY_PREFIX","sessionCookieName","ssrFallback","state","w","getRegistered","state","getRegisteredSlots","getRegisteredSections","subscribeRegistry","fn","listeners","getRegistryVersion","store","w","setVariantOverride","componentId","variantId","clearVariantOverride","getOverrides","__spreadValues","store","w","setSlotOverride","slotId","result","clearSlotOverride","getSlotOverrides","__spreadValues","ssrFallback","state","w","setPreviewMode","on","s","fn","getPreviewMode","EVENT","notifyOverridesChanged","_a","w","EVENT","readDevtoolsConfig","_a","jsx","jsxs","_a","IS_PROD","DEFAULT_API_BASE_URL","LOCAL_MODE_DEVTOOLS_BANNER","currentLayout","forced","registered","getRegisteredSections","id","reorderLayout","from","to","order","next","moved","setPreviewMode","notifyOverridesChanged","resetLayout","applyOutcome","result","_b","variantId","setVariantOverride","w","__spreadValues","readSessionId","apiKey","read","name","match","e","sessionCookieName","LEGACY_SESSION_COOKIE_NAME","slotDecls","getRegisteredSlots","s","UNKNOWN_CHOICE","UNKNOWN_PERSONA","UNKNOWN_PERSONA_DISPLAY","fetchPersonaVocabulary","apiBaseUrl","res","data","valid","list","p","personas","previewContextParam","v","forcePersonaKeyed","persona","_c","getRegistered","c","__spreadProps","forcePersonaLocal","mod","outcome","confidenceBand","resetAll","getOverrides","clearVariantOverride","stale","i","key","SNAPSHOT_STORAGE_KEY_PREFIX","btn","active","SentientMark","size","AdaptiveDevtools","open","setOpen","useState","activePersona","setActivePersona","vocab","setVocab","customKey","setCustomKey","discovered","setDiscovered","personaNote","setPersonaNote","dragFrom","setDragFrom","mounted","setMounted","force","useReducer","n","useSyncExternalStore","subscribeRegistry","getRegistryVersion","useEffect","cfg","readDevtoolsConfig","cancelled","config","useLocalEngine","components","slots","overrides","slotOverrides","getSlotOverrides","sections","layoutForced","onReorder","onResetLayout","maybeExitPreview","choose","resetVariant","chooseSlotArm","arm","setSlotOverride","chooseSlotDim","dim","value","dims","current","d","values","resetSlot","clearSlotOverride","choosePersona","member","r","getPreviewMode","normalizeDeclaredPersona","ov","o"]}
package/dist/index.d.cts CHANGED
@@ -22,6 +22,14 @@ type AdaptiveProviderProps = {
22
22
  * the first paint see real content (recommended for SEO).
23
23
  */
24
24
  initialAssignments?: Record<string, string>;
25
+ /**
26
+ * Component ids the SSR preload found moved onto the shared track (the
27
+ * `unified` of `loadAdaptiveAssignments()` / `loadAdaptiveDecision()`;
28
+ * `<AdaptiveRoot>` passes it for you). A variants-only `<Adaptive>` with one
29
+ * of these ids renders on the shared track from the server HTML on, and an
30
+ * assignment cached before the move is ignored.
31
+ */
32
+ initialUnified?: string[];
25
33
  /**
26
34
  * Bandit segment from SSR (`device:source`). Keeps cache, assign, and worker
27
35
  * weights on one row — must match `loadAdaptiveAssignments` / session upsert.
@@ -310,8 +318,31 @@ type AdaptiveSlotProps = {
310
318
  * replace. Set false for a slot wrapping personalized or account content —
311
319
  * the text of THIS region is all that is ever read, never the page. */
312
320
  reportBaselineText?: boolean;
321
+ /** Funnel this component serves (stable funnel id). Same meaning as on a
322
+ * variants-only `<Adaptive>`: declares membership (and, for a
323
+ * weighted_composite goal, the funnel's steps) once per page load. */
324
+ funnel?: string;
325
+ /** Also record a named goal when a passive micro-signal fires here (e.g.
326
+ * rage_click → 'confused_by_hero'). Recorded only for a served arm, and
327
+ * credited to the component like `goal`. */
328
+ microSignalGoals?: MicroSignalGoals;
329
+ /** Render nothing during SSR and before client hydration. */
330
+ clientOnly?: boolean;
331
+ /** Per-arm structured data for AI agents, keyed by the authored key for a
332
+ * hand-written arm and by arm id for a generated one. Only the served arm's
333
+ * entry is sent. Captured at MOUNT, like on a variants-only `<Adaptive>`. */
334
+ agentDataByVariant?: Record<string, unknown>;
335
+ /** @deprecated Use agentDataByVariant. Sent for any served arm that has no
336
+ * entry of its own. Captured at MOUNT. */
337
+ agentData?: unknown;
338
+ /** @internal Set by `<Adaptive variants>` (no children) once the server says
339
+ * its id was migrated onto the shared track. `children` is then the FIRST
340
+ * variant, not an original: the page tells decide it has no children, so
341
+ * the first authored key is the control and the 'baseline' arm — which
342
+ * would render that same first variant under another id — is never drawn. */
343
+ variantsOnly?: boolean;
313
344
  };
314
- declare function AdaptiveSlot({ id, children, variants, onFormSubmit, goal, className, as: Tag, reportBaselineText, }: AdaptiveSlotProps): JSX.Element;
345
+ declare function AdaptiveSlot({ id, children, variants, onFormSubmit, goal, className, as: Tag, reportBaselineText, funnel, microSignalGoals, clientOnly, agentDataByVariant, agentData, variantsOnly, }: AdaptiveSlotProps): JSX.Element | null;
315
346
 
316
347
  /** `<Adaptive>` with variants written in code — each key an arm, first key the control. */
317
348
  type AdaptiveVariantsProps = {
@@ -447,7 +478,14 @@ type AssignmentState = {
447
478
  * on the next render. Subsequent paints read synchronously from cache —
448
479
  * no flicker, no loading state after first paint.
449
480
  */
450
- declare function useAssignment(componentId: string, variantIds: string[], agentData?: unknown, agentDataByVariant?: Record<string, unknown>): AssignmentState;
481
+ declare function useAssignment(componentId: string, variantIds: string[], agentData?: unknown, agentDataByVariant?: Record<string, unknown>,
482
+ /** `onUnified`: the caller can render this component on the shared track.
483
+ * The assign then carries the unified cap, and a `unified` answer calls this
484
+ * INSTEAD of settling — it is not an assignment, and settling on its
485
+ * placeholder would expose that variant on a frozen ledger. */
486
+ opts?: {
487
+ onUnified?: () => void;
488
+ }): AssignmentState;
451
489
 
452
490
  interface FireGoalOptions extends ComponentGoalOptions {
453
491
  /**
package/dist/index.d.ts CHANGED
@@ -22,6 +22,14 @@ type AdaptiveProviderProps = {
22
22
  * the first paint see real content (recommended for SEO).
23
23
  */
24
24
  initialAssignments?: Record<string, string>;
25
+ /**
26
+ * Component ids the SSR preload found moved onto the shared track (the
27
+ * `unified` of `loadAdaptiveAssignments()` / `loadAdaptiveDecision()`;
28
+ * `<AdaptiveRoot>` passes it for you). A variants-only `<Adaptive>` with one
29
+ * of these ids renders on the shared track from the server HTML on, and an
30
+ * assignment cached before the move is ignored.
31
+ */
32
+ initialUnified?: string[];
25
33
  /**
26
34
  * Bandit segment from SSR (`device:source`). Keeps cache, assign, and worker
27
35
  * weights on one row — must match `loadAdaptiveAssignments` / session upsert.
@@ -310,8 +318,31 @@ type AdaptiveSlotProps = {
310
318
  * replace. Set false for a slot wrapping personalized or account content —
311
319
  * the text of THIS region is all that is ever read, never the page. */
312
320
  reportBaselineText?: boolean;
321
+ /** Funnel this component serves (stable funnel id). Same meaning as on a
322
+ * variants-only `<Adaptive>`: declares membership (and, for a
323
+ * weighted_composite goal, the funnel's steps) once per page load. */
324
+ funnel?: string;
325
+ /** Also record a named goal when a passive micro-signal fires here (e.g.
326
+ * rage_click → 'confused_by_hero'). Recorded only for a served arm, and
327
+ * credited to the component like `goal`. */
328
+ microSignalGoals?: MicroSignalGoals;
329
+ /** Render nothing during SSR and before client hydration. */
330
+ clientOnly?: boolean;
331
+ /** Per-arm structured data for AI agents, keyed by the authored key for a
332
+ * hand-written arm and by arm id for a generated one. Only the served arm's
333
+ * entry is sent. Captured at MOUNT, like on a variants-only `<Adaptive>`. */
334
+ agentDataByVariant?: Record<string, unknown>;
335
+ /** @deprecated Use agentDataByVariant. Sent for any served arm that has no
336
+ * entry of its own. Captured at MOUNT. */
337
+ agentData?: unknown;
338
+ /** @internal Set by `<Adaptive variants>` (no children) once the server says
339
+ * its id was migrated onto the shared track. `children` is then the FIRST
340
+ * variant, not an original: the page tells decide it has no children, so
341
+ * the first authored key is the control and the 'baseline' arm — which
342
+ * would render that same first variant under another id — is never drawn. */
343
+ variantsOnly?: boolean;
313
344
  };
314
- declare function AdaptiveSlot({ id, children, variants, onFormSubmit, goal, className, as: Tag, reportBaselineText, }: AdaptiveSlotProps): JSX.Element;
345
+ declare function AdaptiveSlot({ id, children, variants, onFormSubmit, goal, className, as: Tag, reportBaselineText, funnel, microSignalGoals, clientOnly, agentDataByVariant, agentData, variantsOnly, }: AdaptiveSlotProps): JSX.Element | null;
315
346
 
316
347
  /** `<Adaptive>` with variants written in code — each key an arm, first key the control. */
317
348
  type AdaptiveVariantsProps = {
@@ -447,7 +478,14 @@ type AssignmentState = {
447
478
  * on the next render. Subsequent paints read synchronously from cache —
448
479
  * no flicker, no loading state after first paint.
449
480
  */
450
- declare function useAssignment(componentId: string, variantIds: string[], agentData?: unknown, agentDataByVariant?: Record<string, unknown>): AssignmentState;
481
+ declare function useAssignment(componentId: string, variantIds: string[], agentData?: unknown, agentDataByVariant?: Record<string, unknown>,
482
+ /** `onUnified`: the caller can render this component on the shared track.
483
+ * The assign then carries the unified cap, and a `unified` answer calls this
484
+ * INSTEAD of settling — it is not an assignment, and settling on its
485
+ * placeholder would expose that variant on a frozen ledger. */
486
+ opts?: {
487
+ onUnified?: () => void;
488
+ }): AssignmentState;
451
489
 
452
490
  interface FireGoalOptions extends ComponentGoalOptions {
453
491
  /**