@syntrologie/adapt-chatbot 2.8.0-canary.43 → 2.8.0-canary.430

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 (178) hide show
  1. package/dist/AdaptiveChatBar.d.ts +175 -0
  2. package/dist/AdaptiveChatBar.d.ts.map +1 -0
  3. package/dist/AdaptiveChatBar.js +11 -0
  4. package/dist/AdaptiveChatBar.js.map +7 -0
  5. package/dist/AdaptiveChatBarMountable.d.ts +80 -0
  6. package/dist/AdaptiveChatBarMountable.d.ts.map +1 -0
  7. package/dist/AdaptiveChatTrail.anchor-scroll.test.d.ts +2 -0
  8. package/dist/AdaptiveChatTrail.anchor-scroll.test.d.ts.map +1 -0
  9. package/dist/AdaptiveChatTrail.d.ts +415 -0
  10. package/dist/AdaptiveChatTrail.d.ts.map +1 -0
  11. package/dist/AdaptiveChatTrail.js +11 -0
  12. package/dist/AdaptiveChatTrail.js.map +7 -0
  13. package/dist/AdaptiveChatTrail.test.d.ts +2 -0
  14. package/dist/AdaptiveChatTrail.test.d.ts.map +1 -0
  15. package/dist/AdaptiveChipsStrip.d.ts +1150 -0
  16. package/dist/AdaptiveChipsStrip.d.ts.map +1 -0
  17. package/dist/AdaptiveChipsStrip.js +11 -0
  18. package/dist/AdaptiveChipsStrip.js.map +7 -0
  19. package/dist/AdaptiveChipsStripMountable.d.ts +24 -0
  20. package/dist/AdaptiveChipsStripMountable.d.ts.map +1 -0
  21. package/dist/ChatAssistantLit.d.ts +60 -0
  22. package/dist/ChatAssistantLit.d.ts.map +1 -0
  23. package/dist/ChatAssistantLit.js +13 -0
  24. package/dist/ChatAssistantLit.js.map +7 -0
  25. package/dist/ChatSession.d.ts +230 -0
  26. package/dist/ChatSession.d.ts.map +1 -0
  27. package/dist/ChatTransport.d.ts +360 -0
  28. package/dist/ChatTransport.d.ts.map +1 -0
  29. package/dist/InlineRegistryWidgetMount.test.d.ts +2 -0
  30. package/dist/InlineRegistryWidgetMount.test.d.ts.map +1 -0
  31. package/dist/InlineWidgetLiveMount.test.d.ts +2 -0
  32. package/dist/InlineWidgetLiveMount.test.d.ts.map +1 -0
  33. package/dist/NavLinkMountable.d.ts +25 -0
  34. package/dist/NavLinkMountable.d.ts.map +1 -0
  35. package/dist/NavLinkMountable.test.d.ts +2 -0
  36. package/dist/NavLinkMountable.test.d.ts.map +1 -0
  37. package/dist/TextAnswerMountable.d.ts +17 -0
  38. package/dist/TextAnswerMountable.d.ts.map +1 -0
  39. package/dist/TextAnswerMountable.test.d.ts +2 -0
  40. package/dist/TextAnswerMountable.test.d.ts.map +1 -0
  41. package/dist/Turnstile.d.ts +83 -0
  42. package/dist/Turnstile.d.ts.map +1 -0
  43. package/dist/cdn.d.ts +2 -6
  44. package/dist/cdn.d.ts.map +1 -1
  45. package/dist/chunk-5W75LR6M.js +460 -0
  46. package/dist/chunk-5W75LR6M.js.map +7 -0
  47. package/dist/chunk-7WSMNAKW.js +3824 -0
  48. package/dist/chunk-7WSMNAKW.js.map +7 -0
  49. package/dist/chunk-EWPPVPJ4.js +14 -0
  50. package/dist/chunk-EWPPVPJ4.js.map +7 -0
  51. package/dist/chunk-GP4OSTZT.js +641 -0
  52. package/dist/chunk-GP4OSTZT.js.map +7 -0
  53. package/dist/chunk-HELUC5JI.js +8971 -0
  54. package/dist/chunk-HELUC5JI.js.map +7 -0
  55. package/dist/chunk-HVGQJZMP.js +1520 -0
  56. package/dist/chunk-HVGQJZMP.js.map +7 -0
  57. package/dist/chunk-KPWW7N27.js +235 -0
  58. package/dist/chunk-KPWW7N27.js.map +7 -0
  59. package/dist/chunk-UVKRO5ER.js +13 -0
  60. package/dist/chunk-UVKRO5ER.js.map +7 -0
  61. package/dist/editor-lit.d.ts +37 -0
  62. package/dist/editor-lit.d.ts.map +1 -0
  63. package/dist/editor-lit.js +134 -0
  64. package/dist/editor-lit.js.map +7 -0
  65. package/dist/elements/ActionHandler.d.ts +34 -0
  66. package/dist/elements/ActionHandler.d.ts.map +1 -0
  67. package/dist/elements/ElementInstanceStore.d.ts +207 -0
  68. package/dist/elements/ElementInstanceStore.d.ts.map +1 -0
  69. package/dist/elements/ElementInstanceStore.test.d.ts +2 -0
  70. package/dist/elements/ElementInstanceStore.test.d.ts.map +1 -0
  71. package/dist/elements/ElementTypeHandler.d.ts +77 -0
  72. package/dist/elements/ElementTypeHandler.d.ts.map +1 -0
  73. package/dist/elements/ItemHandler.d.ts +60 -0
  74. package/dist/elements/ItemHandler.d.ts.map +1 -0
  75. package/dist/elements/ItemHandler.test.d.ts +2 -0
  76. package/dist/elements/ItemHandler.test.d.ts.map +1 -0
  77. package/dist/elements/TileHandler.d.ts +52 -0
  78. package/dist/elements/TileHandler.d.ts.map +1 -0
  79. package/dist/elements/TileHandler.test.d.ts +2 -0
  80. package/dist/elements/TileHandler.test.d.ts.map +1 -0
  81. package/dist/elements/__tests__/ElementInstanceStore.recall.test.d.ts +2 -0
  82. package/dist/elements/__tests__/ElementInstanceStore.recall.test.d.ts.map +1 -0
  83. package/dist/elements/blockRenderer.d.ts +46 -0
  84. package/dist/elements/blockRenderer.d.ts.map +1 -0
  85. package/dist/elements/blockRenderer.test.d.ts +13 -0
  86. package/dist/elements/blockRenderer.test.d.ts.map +1 -0
  87. package/dist/elements/blocks.d.ts +58 -0
  88. package/dist/elements/blocks.d.ts.map +1 -0
  89. package/dist/elements/envelope.d.ts +24 -0
  90. package/dist/elements/envelope.d.ts.map +1 -0
  91. package/dist/elements/fetcher.d.ts +40 -0
  92. package/dist/elements/fetcher.d.ts.map +1 -0
  93. package/dist/elements/index.d.ts +33 -0
  94. package/dist/elements/index.d.ts.map +1 -0
  95. package/dist/elements/store-singleton.d.ts +4 -0
  96. package/dist/elements/store-singleton.d.ts.map +1 -0
  97. package/dist/elements/types.d.ts +106 -0
  98. package/dist/elements/types.d.ts.map +1 -0
  99. package/dist/observer/__tests__/allowlist.test.d.ts +9 -0
  100. package/dist/observer/__tests__/allowlist.test.d.ts.map +1 -0
  101. package/dist/observer/__tests__/bus-translate.test.d.ts +16 -0
  102. package/dist/observer/__tests__/bus-translate.test.d.ts.map +1 -0
  103. package/dist/observer/__tests__/lifecycle.test.d.ts +2 -0
  104. package/dist/observer/__tests__/lifecycle.test.d.ts.map +1 -0
  105. package/dist/observer/__tests__/observer-enrich.test.d.ts +10 -0
  106. package/dist/observer/__tests__/observer-enrich.test.d.ts.map +1 -0
  107. package/dist/observer/__tests__/observer-isolation.test.d.ts +13 -0
  108. package/dist/observer/__tests__/observer-isolation.test.d.ts.map +1 -0
  109. package/dist/observer/__tests__/queue.test.d.ts +2 -0
  110. package/dist/observer/__tests__/queue.test.d.ts.map +1 -0
  111. package/dist/observer/__tests__/transport.test.d.ts +2 -0
  112. package/dist/observer/__tests__/transport.test.d.ts.map +1 -0
  113. package/dist/observer/allowlist.d.ts +30 -0
  114. package/dist/observer/allowlist.d.ts.map +1 -0
  115. package/dist/observer/bus-translate.d.ts +33 -0
  116. package/dist/observer/bus-translate.d.ts.map +1 -0
  117. package/dist/observer/index.d.ts +44 -0
  118. package/dist/observer/index.d.ts.map +1 -0
  119. package/dist/observer/queue.d.ts +63 -0
  120. package/dist/observer/queue.d.ts.map +1 -0
  121. package/dist/observer/transport.d.ts +27 -0
  122. package/dist/observer/transport.d.ts.map +1 -0
  123. package/dist/runtime-lit.d.ts +8 -0
  124. package/dist/runtime-lit.d.ts.map +1 -0
  125. package/dist/runtime.d.ts +10 -3
  126. package/dist/runtime.d.ts.map +1 -1
  127. package/dist/runtime.js +2232 -29
  128. package/dist/runtime.js.map +7 -0
  129. package/dist/schema.d.ts +3340 -11
  130. package/dist/schema.d.ts.map +1 -1
  131. package/dist/schema.js +220 -31
  132. package/dist/schema.js.map +7 -0
  133. package/dist/test/setup.d.ts +1 -0
  134. package/dist/test/setup.d.ts.map +1 -0
  135. package/dist/types.d.ts +61 -40
  136. package/dist/types.d.ts.map +1 -1
  137. package/package.json +44 -23
  138. package/dist/ChatAssistant.d.ts +0 -18
  139. package/dist/ChatAssistant.d.ts.map +0 -1
  140. package/dist/ChatAssistant.js +0 -178
  141. package/dist/SyntroChatbot.d.ts +0 -14
  142. package/dist/SyntroChatbot.d.ts.map +0 -1
  143. package/dist/SyntroChatbot.js +0 -56
  144. package/dist/actionParser.d.ts +0 -15
  145. package/dist/actionParser.d.ts.map +0 -1
  146. package/dist/actionParser.js +0 -52
  147. package/dist/apiClient.d.ts +0 -23
  148. package/dist/apiClient.d.ts.map +0 -1
  149. package/dist/apiClient.js +0 -51
  150. package/dist/cdn.js +0 -37
  151. package/dist/editor.d.ts +0 -17
  152. package/dist/editor.d.ts.map +0 -1
  153. package/dist/editor.js +0 -36
  154. package/dist/tools/bridge.d.ts +0 -26
  155. package/dist/tools/bridge.d.ts.map +0 -1
  156. package/dist/tools/bridge.js +0 -25
  157. package/dist/tools/expanders.d.ts +0 -17
  158. package/dist/tools/expanders.d.ts.map +0 -1
  159. package/dist/tools/expanders.js +0 -41
  160. package/dist/tools/index.d.ts +0 -14
  161. package/dist/tools/index.d.ts.map +0 -1
  162. package/dist/tools/index.js +0 -11
  163. package/dist/tools/registrations/GetContextTool.d.ts +0 -7
  164. package/dist/tools/registrations/GetContextTool.d.ts.map +0 -1
  165. package/dist/tools/registrations/GetContextTool.js +0 -18
  166. package/dist/tools/registrations/ScrollToTool.d.ts +0 -7
  167. package/dist/tools/registrations/ScrollToTool.d.ts.map +0 -1
  168. package/dist/tools/registrations/ScrollToTool.js +0 -38
  169. package/dist/tools/registrations/ShowOverlayTool.d.ts +0 -7
  170. package/dist/tools/registrations/ShowOverlayTool.d.ts.map +0 -1
  171. package/dist/tools/registrations/ShowOverlayTool.js +0 -47
  172. package/dist/tools/registrations/index.d.ts +0 -19
  173. package/dist/tools/registrations/index.d.ts.map +0 -1
  174. package/dist/tools/registrations/index.js +0 -7
  175. package/dist/types.js +0 -6
  176. package/dist/useChat.d.ts +0 -25
  177. package/dist/useChat.d.ts.map +0 -1
  178. package/dist/useChat.js +0 -106
@@ -0,0 +1,415 @@
1
+ /**
2
+ * AdaptiveChatTrail — the "bubble-up" message column that sits above the
3
+ * chat bar in the canvas lid.
4
+ *
5
+ * Messages appear immediately above the chat bar and drift upward as
6
+ * newer ones arrive. Each stack position carries an opacity + blur
7
+ * falloff so older messages read as fading from the page. Beyond a
8
+ * `visibleCount` cap (default 3) the trail collapses into an "N more ·
9
+ * expand" affordance — clicking emits `trail-expand`.
10
+ *
11
+ * Shadow DOM (default Lit open root) so chip styles, markdown reset
12
+ * rules, and animation @keyframes are scoped to this element's tree.
13
+ * Theme CSS variables (--sc-tile-text-color, --sc-content-bubble-*,
14
+ * etc.) inherit through the shadow boundary, so canvas-level theming
15
+ * still reaches the chips. The earlier light-DOM render-root override
16
+ * silently broke @keyframes lookup once the trail was hosted inside
17
+ * any shadow root (sc-mount, velvet-mobile, etc.) — keyframes injected
18
+ * into `document.head` aren't visible from another tree scope.
19
+ *
20
+ * See PRD §4.3 (chat trail) for the canonical motion + falloff spec.
21
+ */
22
+ import { LitElement, nothing } from 'lit';
23
+ export interface TrailToolCall {
24
+ id: string;
25
+ name: string;
26
+ status: 'args-streaming' | 'pending' | 'running' | 'done' | 'error';
27
+ /**
28
+ * Parsed tool-call arguments, when available. Threaded through from
29
+ * the AG-UI `ToolCall.args` so the trail can render argument-derived
30
+ * affordances WITHOUT a new transport: an activity receipt for a
31
+ * `primary_response_action` mount (derives type + label from
32
+ * `template_id` / `content.title`) and inline reply chips for a
33
+ * `suggest_replies` call (reads the `replies` array). Undefined while
34
+ * args are still streaming or for tools whose args we don't surface.
35
+ */
36
+ args?: Record<string, unknown>;
37
+ }
38
+ export interface TrailMessage {
39
+ /** Stable identity for keyed rendering (must be unique within the trail). */
40
+ id: number | string;
41
+ role: 'user' | 'assistant' | 'system';
42
+ text: string;
43
+ /** Streaming → assistant text still arriving from backend. Complete → final. Error → fatal during stream. */
44
+ status?: 'streaming' | 'complete' | 'error';
45
+ /** Tool calls attached to an assistant message (rendered as compact chips). */
46
+ toolCalls?: TrailToolCall[];
47
+ }
48
+ export type TileReceipt = {
49
+ kind: 'tile';
50
+ instanceId: string;
51
+ title: string;
52
+ dismissed: boolean;
53
+ } | {
54
+ kind: 'alert';
55
+ instanceId: string;
56
+ title: string;
57
+ };
58
+ /**
59
+ * A widget the backend wants rendered INLINE IN THE CHAT TRAIL (in the
60
+ * conversation flow, like a rich message) — currently the reco carousel.
61
+ * Sourced from `ElementInstanceStore.listInlineWidgets()` (backend
62
+ * `chat-inline` slot mounts) and forwarded by AdaptiveChatBar.
63
+ *
64
+ * The trail mounts `tag` by name via `document.createElement` and assigns
65
+ * the payload as one `props` object property (`el.props = props`, the
66
+ * standard tile-widget mount contract) — it never imports the widget package (the
67
+ * element self-defines when its own bundle loads; on demos both bundles
68
+ * are present). If `tag` is not a defined custom element, the trail
69
+ * renders NOTHING for it (no broken box).
70
+ */
71
+ export interface InlineTrailWidget {
72
+ instanceId: string;
73
+ /**
74
+ * The mount identifier for the widget. For self-defining, server-mounted
75
+ * widgets this IS the custom-element tag (e.g. `syntro-product-reco-carousel`)
76
+ * and the trail creates it directly. For admin-template widgets it is the
77
+ * runtime widget-id (e.g. `adaptive-product:card`, `adaptive-faq:accordion`),
78
+ * which is NOT a valid custom-element tag — those mount through the runtime
79
+ * widget registry via {@link InlineWidgetMounter}, which resolves the id to
80
+ * its real element exactly like the deck `SyntroTileCard` path.
81
+ */
82
+ tag: string;
83
+ props: Record<string, unknown>;
84
+ }
85
+ /**
86
+ * Mounts a registry-registered widget (by its runtime widget-id) into
87
+ * `container` and returns the created element plus an unmount cleanup.
88
+ * Injected from the chat-bar mountable, bound to `runtime.widgets`. Lets the
89
+ * trail render inline tiles whose widget-id is not their custom-element tag
90
+ * (product card, comparison, FAQ accordion) — the registry owns the
91
+ * id → element resolution. Returns `null` when the id is not registered.
92
+ */
93
+ export type InlineWidgetMounter = (widgetId: string, container: HTMLElement, props: Record<string, unknown>) => {
94
+ element: HTMLElement;
95
+ cleanup: () => void;
96
+ } | null;
97
+ export declare class AdaptiveChatTrail extends LitElement {
98
+ static styles: import("lit").CSSResult;
99
+ static properties: {
100
+ messages: {
101
+ attribute: boolean;
102
+ };
103
+ visibleCount: {
104
+ type: NumberConstructor;
105
+ };
106
+ expanded: {
107
+ type: BooleanConstructor;
108
+ };
109
+ greeting: {
110
+ type: StringConstructor;
111
+ };
112
+ /** When true: trail renders fully expanded AND the
113
+ * expand/collapse affordance is hidden. Used by hosts that mount
114
+ * the chat in a full-screen surface (the mobile panel) where
115
+ * collapse makes no sense — there's nothing to collapse INTO. */
116
+ forceExpanded: {
117
+ type: BooleanConstructor;
118
+ };
119
+ /**
120
+ * Mirrors `chatSession.inFlight` — true between `send()` and the
121
+ * assistant's first `receiveStart`/`receiveDelta`, OR while a
122
+ * stream is in progress. Drives the "thinking" indicator that
123
+ * fills the gap between the user's just-sent message and the
124
+ * first assistant token. Wired through AdaptiveChatBar (it owns
125
+ * the chatSession subscription and forwards inFlight as a prop).
126
+ */
127
+ inFlight: {
128
+ type: BooleanConstructor;
129
+ };
130
+ /**
131
+ * Live reasoning narration streamed from the model via AG-UI
132
+ * `THINKING_TEXT_MESSAGE_CONTENT`. When non-empty, the thinking
133
+ * chip renders this in place of the bouncing dots so the visitor
134
+ * sees what the model is actually doing instead of staring at
135
+ * silent loading state during a tool-call gap.
136
+ */
137
+ thinkingText: {
138
+ attribute: boolean;
139
+ };
140
+ /**
141
+ * Pre-conversation suggestion chip. When the visitor opens the
142
+ * chat and `messages` is empty, the trail renders this as a
143
+ * button beneath the greeting. Clicking it dispatches a
144
+ * `trail-intro-suggestion` event with the configured prompt —
145
+ * the parent (chat-bar) forwards that to chatSession.send().
146
+ * Disappears the moment the first message lands.
147
+ */
148
+ introSuggestion: {
149
+ attribute: boolean;
150
+ };
151
+ /**
152
+ * Tappable tile-receipt chips rendered once at the end of the
153
+ * trail. Produced from the store by Task 3 (AdaptiveChatBar).
154
+ * Each chip emits `tile-receipt-activate` with its instanceId.
155
+ */
156
+ tileReceipts: {
157
+ attribute: boolean;
158
+ };
159
+ /**
160
+ * Widgets rendered INLINE in the trail (reco carousel etc.),
161
+ * anchored to a message position like receipts. Sourced from the
162
+ * store's `chat-inline` slot mounts via AdaptiveChatBar.
163
+ */
164
+ inlineWidgets: {
165
+ attribute: boolean;
166
+ };
167
+ /**
168
+ * Registry-backed mounter for inline widgets whose id is not their
169
+ * custom-element tag. Injected from the chat-bar mountable.
170
+ */
171
+ mountInlineWidget: {
172
+ attribute: boolean;
173
+ };
174
+ _messagesBelow: {
175
+ state: boolean;
176
+ };
177
+ };
178
+ messages: TrailMessage[];
179
+ tileReceipts: TileReceipt[];
180
+ inlineWidgets: InlineTrailWidget[];
181
+ mountInlineWidget: InlineWidgetMounter | undefined;
182
+ visibleCount: number;
183
+ expanded: boolean;
184
+ forceExpanded: boolean;
185
+ inFlight: boolean;
186
+ thinkingText: string;
187
+ introSuggestion: {
188
+ label: string;
189
+ prompt: string;
190
+ } | undefined;
191
+ /**
192
+ * Pre-conversation phantom assistant message. Rendered only when
193
+ * `messages` is empty. NOT injected into chatSession state — the
194
+ * greeting is configuration, not conversation, so it disappears
195
+ * automatically when the first real message arrives.
196
+ */
197
+ greeting: string | undefined;
198
+ /** Follow the bottom on content growth. On by default (history
199
+ * browsing); off from a new user message until the visitor opts back in
200
+ * (pill tap or a user-gesture scroll that reaches the bottom). */
201
+ private _stickToBottom;
202
+ /** The user message the current turn is anchored to. */
203
+ private _anchorMsgId;
204
+ /** Whether a turn anchor is live (drives expand-mid-turn landing). */
205
+ private _anchorActive;
206
+ /** Keep enforcing chip-at-top on updates (late geometry, mode flips)
207
+ * until the user scrolls or opts into following. */
208
+ private _anchorHold;
209
+ /** Number of messages whose BOTTOM edge is still below the viewport —
210
+ * messages the visitor hasn't scrolled past yet. Drives the
211
+ * "⌄ N messages" pill and stays accurate as they scroll (one long
212
+ * streaming reply counts as 1 until its end has been read). Reactive. */
213
+ private _messagesBelow;
214
+ /** Timestamp of the last user scroll gesture (wheel/touch): scroll
215
+ * events outside this window are programmatic (our own pin/anchor) and
216
+ * must not re-engage following — anchoring the newest message clamps AT
217
+ * the bottom in any longer conversation. */
218
+ private _lastUserScrollIntentTs;
219
+ private static readonly _AT_BOTTOM_EPSILON_PX;
220
+ private static readonly _USER_SCROLL_INTENT_WINDOW_MS;
221
+ private get _scrollable();
222
+ private _trailContainer;
223
+ private _isAtBottom;
224
+ /** Count chips whose bottom edge hasn't entered the viewport yet. */
225
+ private _countMessagesBelow;
226
+ private _syncContentBelow;
227
+ private _markUserScrollIntent;
228
+ private _onTrailScroll;
229
+ /** Pill tap: jump to the newest content and follow for the rest of the turn. */
230
+ private _onScrollToRecent;
231
+ /** Scroll so the anchored user chip sits at the top of the trail
232
+ * viewport. Idempotent — safe to re-apply on every update while the
233
+ * hold is live (content grows BELOW the anchor, so the target is
234
+ * stable; re-applying also covers late geometry, e.g. expanding
235
+ * mid-turn from the ambient strip). */
236
+ private _applyAnchor;
237
+ private _pinToBottom;
238
+ private _onExpand;
239
+ /**
240
+ * Approve a pending client tool call. The trail emits a generic
241
+ * event so the host can decide whether to forward to chatSession
242
+ * (the common path) or override. Keeps the trail itself free of
243
+ * direct chatSession coupling — it's a pure view component.
244
+ */
245
+ private _onToolCallClick;
246
+ private _onCollapse;
247
+ /**
248
+ * Whether to render the thinking-dots chip after the last message.
249
+ * True iff a request is in flight AND the assistant hasn't started
250
+ * streaming a reply yet — once the first delta lands, the streaming
251
+ * chip's caret takes over and the thinking indicator hides so the
252
+ * visitor isn't shown both at once. Also hidden when the last
253
+ * message is an error/system message, because the request that
254
+ * "errored" is already over from the user's perspective.
255
+ */
256
+ private _shouldShowThinking;
257
+ /**
258
+ * instanceId → id of the message that was newest when the receipt first
259
+ * appeared. This is what makes a receipt read like a chat bubble: it renders
260
+ * inline right after its anchor message, so newer messages push it up into
261
+ * history instead of it staying pinned below everything. Assigned once per
262
+ * instanceId (in willUpdate, the only place that sees both `messages` and
263
+ * `tileReceipts` at the moment a tile mounts) and never re-homed — a
264
+ * dismiss/bring-back keeps the chip where it was created. `null` = the tile
265
+ * mounted before the first chat message (canvas replay); those fall to the
266
+ * tail strip (see render).
267
+ */
268
+ private readonly _receiptAnchors;
269
+ /**
270
+ * instanceId → anchor message id for inline widgets — same mechanism as
271
+ * `_receiptAnchors`. The inline carousel renders right after the message
272
+ * that was newest when it mounted, so it reads like a rich reply and
273
+ * drifts up into history as later messages append.
274
+ */
275
+ private readonly _inlineAnchors;
276
+ /**
277
+ * instanceId → the cached inline widget entry (render node + props target +
278
+ * optional registry cleanup). Cached so a prop patch (same instanceId, new
279
+ * props) updates the EXISTING element instead of tearing it down and
280
+ * re-creating it — which would reset the carousel's scroll position +
281
+ * internal state. Created lazily the first time we see the widget:
282
+ * `document.createElement(tag)` for a defined tag, or a registry mount for a
283
+ * widget-id. An unresolvable widget caches `null` so the fail-safe renders
284
+ * nothing without re-checking the registry.
285
+ */
286
+ private readonly _inlineElements;
287
+ disconnectedCallback(): void;
288
+ /**
289
+ * The id of the newest message the render will actually PAINT — the only
290
+ * valid anchor target. Anchoring to the raw last message is wrong-by-
291
+ * construction for tool-call turns: mid-turn the newest message is often a
292
+ * whitespace-only assistant shell (some providers emit whitespace text
293
+ * deltas around tool calls) that the empty-bubble filter drops, so an
294
+ * anchor recorded on it can never be in the painted set and the receipt
295
+ * falls to the tail strip forever — resurrecting BUG-1783015943 (seen live
296
+ * on vela desktop, BUG-1783630187). `isSuggestionHost=false` here: a
297
+ * message whose ONLY content is reply chips is too ephemeral to anchor on
298
+ * (the chips clear when the visitor answers), so walk past it too.
299
+ */
300
+ private _newestRenderableMessageId;
301
+ willUpdate(changed: Map<string, unknown>): void;
302
+ /**
303
+ * Create (once) or refresh the cached element for an inline widget.
304
+ *
305
+ * Two mount paths, both keeping the chat bundle free of any widget-package
306
+ * import:
307
+ * - Direct tag (self-defining, server-mounted widgets like the reco
308
+ * carousel whose declared `widget` IS its custom-element tag):
309
+ * `document.createElement(tag)`.
310
+ * - Widget-id (admin-template widgets like `adaptive-product:card` or
311
+ * `adaptive-faq:accordion`, whose `widget` is a runtime widget-id, NOT a
312
+ * valid custom-element tag): mount through the runtime widget registry
313
+ * via {@link mountInlineWidget}, which resolves the id to its real
314
+ * element exactly like the deck `SyntroTileCard` path. Without this,
315
+ * `createElement('adaptive-product:card')` yields an inert unknown
316
+ * element and the tile renders permanently blank (the "inline mode
317
+ * shows nothing but the reco" bug).
318
+ *
319
+ * Fail-safe: an id that resolves to neither a defined tag nor a registered
320
+ * widget caches `null` and renders nothing (no broken box).
321
+ */
322
+ private _ensureInlineElement;
323
+ updated(changed: Map<string, unknown>): void;
324
+ private _onTileReceiptClick;
325
+ private _onAlertReceiptClick;
326
+ /** Render a set of inline widgets (reco carousel etc.) as
327
+ * `[data-trail-widget]` blocks, anchored to a message position like
328
+ * receipts. Each block hosts the cached custom element for that
329
+ * instanceId — a defined tag mounts inline; an undefined tag renders
330
+ * nothing (fail-safe). Rendered at every trail site (inline per anchor,
331
+ * tail, empty-state) so placement can't diverge. */
332
+ private _renderInlineWidgetStrip;
333
+ /** A row of receipt chips, used at every trail render site (inline per
334
+ * anchor message, the tail fallback, and the empty-state branches) so the
335
+ * markup + styling can never diverge. Returns `nothing` for an empty list. */
336
+ private _renderReceiptStrip;
337
+ /** One receipt chip — a single, unified, single-line design for both kinds
338
+ * (nav "alert" + mounted "tile"). Same container/title/action style so they
339
+ * read as one chip family; the icon + action label carry the kind. No
340
+ * subtitle: the old "Brought up earlier" line was hardcoded (wrong for
341
+ * same-turn mounts) and made the chip taller — dropping it is the "shorter"
342
+ * chip. Rendered at every trail site so the kinds can't diverge. */
343
+ private _renderReceiptChip;
344
+ private _onIntroSuggestionClick;
345
+ /**
346
+ * Visitor tapped a `suggest_replies` inline chip. Emit
347
+ * `trail-suggested-reply` carrying the chip text — the parent
348
+ * (AdaptiveChatBar) re-dispatches it as `chat-message-sent`, the
349
+ * SAME channel the input row uses, so the reply rides the existing
350
+ * send path (mountable → chatSession.send → transport). No fabricated
351
+ * AG-UI events; this is exactly what typing the text and hitting
352
+ * Enter would do. The chips clear on their own once the reply lands
353
+ * and a newer assistant message becomes the latest.
354
+ */
355
+ private _onSuggestedReplyClick;
356
+ render(): typeof nothing | import("lit-html").TemplateResult<1>;
357
+ }
358
+ /**
359
+ * Discriminated visual state for a chip. Replaces the older
360
+ * `(role, { isStreaming, isError })` triple whose interaction order
361
+ * could produce nonsense combinations (e.g. an assistant chip
362
+ * accidentally reading as a user bubble because `isStreaming` was
363
+ * checked before role). Each kind below is a real conversational
364
+ * state with a single visual identity:
365
+ *
366
+ * - `settled` — a complete message; the user-vs-assistant
367
+ * identity comes from `role`
368
+ * - `streaming` — the assistant chip currently receiving tokens;
369
+ * keeps assistant identity (the blinking caret
370
+ * inside the chip carries "in progress")
371
+ * - `pending` — the thinking chip shown between the user's
372
+ * just-sent message and the assistant's first
373
+ * token; assistant identity (the bouncing dots
374
+ * inside carry "in progress")
375
+ * - `error` — a chip whose stream failed mid-flight, OR any
376
+ * system-role message (system messages render
377
+ * with the error identity by convention)
378
+ *
379
+ * Bug history: an earlier branch-ladder design checked `isStreaming`
380
+ * before `role`, so the `pending`/thinking chip inherited the user
381
+ * bubble border. On hosts whose chat panel sits over a light surface
382
+ * that read as a "white div" pasted into the assistant slot. The
383
+ * discriminated state prevents that combination from being expressible.
384
+ */
385
+ export type ChipVisualState = {
386
+ kind: 'settled';
387
+ role: 'user' | 'assistant' | 'system';
388
+ } | {
389
+ kind: 'streaming';
390
+ } | {
391
+ kind: 'pending';
392
+ } | {
393
+ kind: 'notice';
394
+ role: 'user' | 'assistant' | 'system';
395
+ };
396
+ /**
397
+ * A misbehaving model can emit a raw SERIALIZED response payload as plain TEXT
398
+ * on a spurious trailing turn — e.g.
399
+ * `(Empty response: {'content': [{'type': 'thinking', …}], 'stop_reason': …})`.
400
+ * Backstop for model degeneration (Kimi); the prompt (S-14) also asks for one
401
+ * brief closing, but copy can't be trusted on the very turn that degenerates.
402
+ *
403
+ * Detection avoids false positives (which are WORSE than the dump — the visitor
404
+ * would see nothing): a turn is dropped only if it OPENS with the literal
405
+ * "(Empty response" marker, OR it carries ≥2 serialization tokens at once. A
406
+ * single token (a product about a "signature blend", the agent quoting one JSON
407
+ * key) never trips it; a real response dump carries all of them.
408
+ */
409
+ export declare function looksLikeSerializedModelResponse(text: string): boolean;
410
+ declare global {
411
+ interface HTMLElementTagNameMap {
412
+ 'adaptive-chat-trail': AdaptiveChatTrail;
413
+ }
414
+ }
415
+ //# sourceMappingURL=AdaptiveChatTrail.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AdaptiveChatTrail.d.ts","sourceRoot":"","sources":["../src/AdaptiveChatTrail.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,EAAa,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAIrD,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,gBAAgB,GAAG,SAAS,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,CAAC;IACpE;;;;;;;;OAQG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;AAED,MAAM,WAAW,YAAY;IAC3B,6EAA6E;IAC7E,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,QAAQ,CAAC;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,6GAA6G;IAC7G,MAAM,CAAC,EAAE,WAAW,GAAG,UAAU,GAAG,OAAO,CAAC;IAC5C,+EAA+E;IAC/E,SAAS,CAAC,EAAE,aAAa,EAAE,CAAC;CAC7B;AAED,MAAM,MAAM,WAAW,GACnB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,S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9
+ looksLikeSerializedModelResponse
10
+ };
11
+ //# sourceMappingURL=AdaptiveChatTrail.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ import './AdaptiveChatTrail';
2
+ //# sourceMappingURL=AdaptiveChatTrail.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AdaptiveChatTrail.test.d.ts","sourceRoot":"","sources":["../src/AdaptiveChatTrail.test.ts"],"names":[],"mappings":"AAgBA,OAAO,qBAAqB,CAAC"}