/** * One place that connects a Syntro runtime to the observer. * * What the shopper does is the same signal wherever they are: on a storefront * page the chat bar wires this, and inside a chat app's card the host agent * controller wires the very same thing. Both post to * `/api/adaptive/observation` with the runtime's own distinct id, so the * backend drains one visitor's timeline whichever surface produced it. * * Extracted from `AdaptiveChatBarMountable` so there is exactly one copy of * the transport options, the identity accessors and the bus translation. * `startObserver` is reference-counted, so several owners share one queue and * the observer tears down when the last one stops. */ import type { ProductIdentityExtractor } from '@syntrologie/sdk-contracts'; import type { ObservationEvent, RawEvent } from './allowlist'; /** What the observer needs from a runtime. Everything else is none of its business. */ export interface ObserverRuntime { events?: { subscribe?: (filter: unknown, cb: (e: unknown) => void) => () => void; }; backendUrl?: string; token?: string; telemetry?: { getDistinctId?: () => string | undefined | null; getSessionId?: () => string | undefined | null; }; /** Active platform adapter's product-identity extractor (undefined off-platform). */ getProductIdentity?: ProductIdentityExtractor; } /** * Observation enrichment (exported for direct testing). * * Two passes through the SAME platform-adapter extractor: * 1. clicks — resolve product identity from the clicked element chain * (original behavior, unchanged); * 2. page-level signals (view/scroll/idle/hesitation/hover/nav) with no * product — resolve the CURRENT page's product by feeding the extractor * a synthetic chain element carrying `location.pathname`. Live-verified * gap (FEAT-1783640628): a visitor ON a PDP produces section views with * no product identity, which starved every product-shaped downstream * (nudge ping-pong detection, the agent's "viewed " context). */ export declare function buildObserverEnrich(runtimeRef: { getProductIdentity?: ProductIdentityExtractor; }): (ev: ObservationEvent, raw: RawEvent) => ObservationEvent; /** * Start observing this runtime's bus and return the owner's stop. * * The stop is idempotent and releases only this owner's reference; the shared * observer keeps running while any other owner holds one. */ export declare function wireObserver(runtime: ObserverRuntime | undefined): () => void; //# sourceMappingURL=wire.d.ts.map