@syntrologie/adapt-chatbot 2.8.0-canary.4 → 2.8.0-canary.400

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 (134) hide show
  1. package/dist/AdaptiveChatBar.d.ts +138 -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 +37 -0
  6. package/dist/AdaptiveChatBarMountable.d.ts.map +1 -0
  7. package/dist/AdaptiveChatTrail.d.ts +256 -0
  8. package/dist/AdaptiveChatTrail.d.ts.map +1 -0
  9. package/dist/AdaptiveChatTrail.js +11 -0
  10. package/dist/AdaptiveChatTrail.js.map +7 -0
  11. package/dist/AdaptiveChipsStrip.d.ts +1150 -0
  12. package/dist/AdaptiveChipsStrip.d.ts.map +1 -0
  13. package/dist/AdaptiveChipsStrip.js +11 -0
  14. package/dist/AdaptiveChipsStrip.js.map +7 -0
  15. package/dist/AdaptiveChipsStripMountable.d.ts +24 -0
  16. package/dist/AdaptiveChipsStripMountable.d.ts.map +1 -0
  17. package/dist/ChatAssistantLit.d.ts +60 -0
  18. package/dist/ChatAssistantLit.d.ts.map +1 -0
  19. package/dist/ChatAssistantLit.js +13 -0
  20. package/dist/ChatAssistantLit.js.map +7 -0
  21. package/dist/ChatSession.d.ts +217 -0
  22. package/dist/ChatSession.d.ts.map +1 -0
  23. package/dist/ChatTransport.d.ts +320 -0
  24. package/dist/ChatTransport.d.ts.map +1 -0
  25. package/dist/NavLinkMountable.d.ts +25 -0
  26. package/dist/NavLinkMountable.d.ts.map +1 -0
  27. package/dist/NavLinkMountable.test.d.ts +2 -0
  28. package/dist/NavLinkMountable.test.d.ts.map +1 -0
  29. package/dist/TextAnswerMountable.d.ts +17 -0
  30. package/dist/TextAnswerMountable.d.ts.map +1 -0
  31. package/dist/Turnstile.d.ts +83 -0
  32. package/dist/Turnstile.d.ts.map +1 -0
  33. package/dist/cdn.d.ts +2 -6
  34. package/dist/cdn.d.ts.map +1 -1
  35. package/dist/chunk-5PW6T3QF.js +3740 -0
  36. package/dist/chunk-5PW6T3QF.js.map +7 -0
  37. package/dist/chunk-CXSEPORE.js +8918 -0
  38. package/dist/chunk-CXSEPORE.js.map +7 -0
  39. package/dist/chunk-EWPPVPJ4.js +14 -0
  40. package/dist/chunk-EWPPVPJ4.js.map +7 -0
  41. package/dist/chunk-FVNSOP7B.js +634 -0
  42. package/dist/chunk-FVNSOP7B.js.map +7 -0
  43. package/dist/chunk-OV6WQZ5F.js +1148 -0
  44. package/dist/chunk-OV6WQZ5F.js.map +7 -0
  45. package/dist/chunk-UVKRO5ER.js +13 -0
  46. package/dist/chunk-UVKRO5ER.js.map +7 -0
  47. package/dist/chunk-VGKCEO6P.js +434 -0
  48. package/dist/chunk-VGKCEO6P.js.map +7 -0
  49. package/dist/chunk-VLJ3WOEX.js +231 -0
  50. package/dist/chunk-VLJ3WOEX.js.map +7 -0
  51. package/dist/editor-lit.d.ts +37 -0
  52. package/dist/editor-lit.d.ts.map +1 -0
  53. package/dist/editor-lit.js +134 -0
  54. package/dist/editor-lit.js.map +7 -0
  55. package/dist/elements/ActionHandler.d.ts +34 -0
  56. package/dist/elements/ActionHandler.d.ts.map +1 -0
  57. package/dist/elements/ElementInstanceStore.d.ts +173 -0
  58. package/dist/elements/ElementInstanceStore.d.ts.map +1 -0
  59. package/dist/elements/ElementInstanceStore.test.d.ts +2 -0
  60. package/dist/elements/ElementInstanceStore.test.d.ts.map +1 -0
  61. package/dist/elements/ElementTypeHandler.d.ts +77 -0
  62. package/dist/elements/ElementTypeHandler.d.ts.map +1 -0
  63. package/dist/elements/ItemHandler.d.ts +60 -0
  64. package/dist/elements/ItemHandler.d.ts.map +1 -0
  65. package/dist/elements/ItemHandler.test.d.ts +2 -0
  66. package/dist/elements/ItemHandler.test.d.ts.map +1 -0
  67. package/dist/elements/TileHandler.d.ts +52 -0
  68. package/dist/elements/TileHandler.d.ts.map +1 -0
  69. package/dist/elements/TileHandler.test.d.ts +2 -0
  70. package/dist/elements/TileHandler.test.d.ts.map +1 -0
  71. package/dist/elements/__tests__/ElementInstanceStore.recall.test.d.ts +2 -0
  72. package/dist/elements/__tests__/ElementInstanceStore.recall.test.d.ts.map +1 -0
  73. package/dist/elements/blockRenderer.d.ts +46 -0
  74. package/dist/elements/blockRenderer.d.ts.map +1 -0
  75. package/dist/elements/blockRenderer.test.d.ts +13 -0
  76. package/dist/elements/blockRenderer.test.d.ts.map +1 -0
  77. package/dist/elements/blocks.d.ts +58 -0
  78. package/dist/elements/blocks.d.ts.map +1 -0
  79. package/dist/elements/envelope.d.ts +24 -0
  80. package/dist/elements/envelope.d.ts.map +1 -0
  81. package/dist/elements/fetcher.d.ts +40 -0
  82. package/dist/elements/fetcher.d.ts.map +1 -0
  83. package/dist/elements/index.d.ts +33 -0
  84. package/dist/elements/index.d.ts.map +1 -0
  85. package/dist/elements/store-singleton.d.ts +4 -0
  86. package/dist/elements/store-singleton.d.ts.map +1 -0
  87. package/dist/elements/types.d.ts +106 -0
  88. package/dist/elements/types.d.ts.map +1 -0
  89. package/dist/observer/__tests__/allowlist.test.d.ts +9 -0
  90. package/dist/observer/__tests__/allowlist.test.d.ts.map +1 -0
  91. package/dist/observer/__tests__/observer-isolation.test.d.ts +13 -0
  92. package/dist/observer/__tests__/observer-isolation.test.d.ts.map +1 -0
  93. package/dist/observer/__tests__/queue.test.d.ts +2 -0
  94. package/dist/observer/__tests__/queue.test.d.ts.map +1 -0
  95. package/dist/observer/__tests__/transport.test.d.ts +2 -0
  96. package/dist/observer/__tests__/transport.test.d.ts.map +1 -0
  97. package/dist/observer/allowlist.d.ts +30 -0
  98. package/dist/observer/allowlist.d.ts.map +1 -0
  99. package/dist/observer/index.d.ts +36 -0
  100. package/dist/observer/index.d.ts.map +1 -0
  101. package/dist/observer/queue.d.ts +57 -0
  102. package/dist/observer/queue.d.ts.map +1 -0
  103. package/dist/observer/transport.d.ts +27 -0
  104. package/dist/observer/transport.d.ts.map +1 -0
  105. package/dist/runtime-lit.d.ts +8 -0
  106. package/dist/runtime-lit.d.ts.map +1 -0
  107. package/dist/runtime.d.ts +10 -3
  108. package/dist/runtime.d.ts.map +1 -1
  109. package/dist/runtime.js +1845 -29
  110. package/dist/runtime.js.map +7 -0
  111. package/dist/schema.d.ts +3334 -11
  112. package/dist/schema.d.ts.map +1 -1
  113. package/dist/schema.js +217 -31
  114. package/dist/schema.js.map +7 -0
  115. package/dist/types.d.ts +47 -31
  116. package/dist/types.d.ts.map +1 -1
  117. package/package.json +51 -19
  118. package/dist/ChatAssistant.d.ts +0 -18
  119. package/dist/ChatAssistant.d.ts.map +0 -1
  120. package/dist/ChatAssistant.js +0 -178
  121. package/dist/actionParser.d.ts +0 -15
  122. package/dist/actionParser.d.ts.map +0 -1
  123. package/dist/actionParser.js +0 -52
  124. package/dist/apiClient.d.ts +0 -23
  125. package/dist/apiClient.d.ts.map +0 -1
  126. package/dist/apiClient.js +0 -51
  127. package/dist/cdn.js +0 -37
  128. package/dist/editor.d.ts +0 -17
  129. package/dist/editor.d.ts.map +0 -1
  130. package/dist/editor.js +0 -36
  131. package/dist/types.js +0 -6
  132. package/dist/useChat.d.ts +0 -25
  133. package/dist/useChat.d.ts.map +0 -1
  134. package/dist/useChat.js +0 -106
@@ -0,0 +1,138 @@
1
+ /**
2
+ * AdaptiveChatBar — the canvas lid composition for the chat-canvas
3
+ * experience. Renders the bubble-up trail on top and an always-visible
4
+ * input row below.
5
+ *
6
+ * Wiring contract (events out):
7
+ * - `chat-message-sent` ({ text }): the user submitted text via Enter
8
+ * or the send button. The owning code is responsible for pushing
9
+ * this into the conversation history and producing a reply.
10
+ *
11
+ * Wiring contract (props in):
12
+ * - `messages`: the conversation trail, passed straight through to
13
+ * `<adaptive-chat-trail>`.
14
+ * - `placeholder`: input placeholder copy. Defaults to a generic
15
+ * "Ask, find, or navigate…" — the host (typically the slot's lid
16
+ * widget mount) can override to a context-specific string.
17
+ *
18
+ * Light DOM. Glassmorphism is applied at the input-row level so the
19
+ * trail above floats over the host page without chrome. See PRD §4.4.
20
+ */
21
+ import { LitElement } from 'lit';
22
+ import './AdaptiveChatTrail.js';
23
+ import type { TileReceipt, TrailMessage } from './AdaptiveChatTrail.js';
24
+ export declare class AdaptiveChatBar extends LitElement {
25
+ static properties: {
26
+ messages: {
27
+ attribute: boolean;
28
+ };
29
+ placeholder: {
30
+ type: StringConstructor;
31
+ };
32
+ greeting: {
33
+ type: StringConstructor;
34
+ };
35
+ inFlight: {
36
+ type: BooleanConstructor;
37
+ reflect: boolean;
38
+ };
39
+ thinkingText: {
40
+ attribute: boolean;
41
+ };
42
+ introSuggestion: {
43
+ attribute: boolean;
44
+ };
45
+ forceExpanded: {
46
+ type: BooleanConstructor;
47
+ reflect: boolean;
48
+ };
49
+ maximized: {
50
+ type: BooleanConstructor;
51
+ };
52
+ tileReceipts: {
53
+ attribute: boolean;
54
+ };
55
+ _input: {
56
+ state: boolean;
57
+ };
58
+ };
59
+ messages: TrailMessage[];
60
+ maximized: boolean;
61
+ tileReceipts: TileReceipt[];
62
+ /**
63
+ * Live reasoning narration from the model — streamed in via
64
+ * AG-UI THINKING_TEXT_MESSAGE_CONTENT events and forwarded by
65
+ * the ChatSession subscription on the host (mountable).
66
+ * Forwarded verbatim to the trail, which renders it in place of
67
+ * the silent loading dots between turns. Empty string when no
68
+ * thinking turn is active.
69
+ */
70
+ thinkingText: string;
71
+ /**
72
+ * Pre-conversation suggestion button — forwarded to the trail's
73
+ * empty-state pane. When the visitor clicks it the trail emits
74
+ * `trail-intro-suggestion`; we catch that here and submit the
75
+ * configured prompt through the normal send path.
76
+ */
77
+ introSuggestion: {
78
+ label: string;
79
+ prompt: string;
80
+ } | undefined;
81
+ /** Pass-through to {@link AdaptiveChatTrail}'s ``forceExpanded`` prop.
82
+ * Hosts that mount the chat-bar in a full-screen surface (mobile
83
+ * panel, agent app, etc.) set this to skip the collapse affordance
84
+ * — there is no smaller state to fall back to. */
85
+ forceExpanded: boolean;
86
+ placeholder: string;
87
+ /**
88
+ * Initial assistant message shown before any real conversation
89
+ * starts. Renders inside the trail as a phantom assistant chip
90
+ * when messages.length === 0; auto-disappears as soon as the
91
+ * first user message lands. Mirrors ChatAssistantLit's greeting.
92
+ */
93
+ greeting: string | undefined;
94
+ /**
95
+ * Whether a chat round-trip is in flight (request sent, awaiting
96
+ * reply). The single send/stop button morphs accordingly: ↑ when
97
+ * ready, ⏹ when in-flight. Parent owns this state — set true after
98
+ * `chat-message-sent` fires, false when the reply lands or the
99
+ * request is aborted. Enter is inert while in-flight.
100
+ */
101
+ inFlight: boolean;
102
+ _input: string;
103
+ createRenderRoot(): HTMLElement;
104
+ connectedCallback(): void;
105
+ disconnectedCallback(): void;
106
+ private _onInput;
107
+ private _onKeyDown;
108
+ private _onSendOrInterrupt;
109
+ private _onTileReceiptActivate;
110
+ private _onAlertReceiptActivate;
111
+ private _onMaximizeToggle;
112
+ private _send;
113
+ /**
114
+ * Visitor tapped the intro suggestion button in the empty-state
115
+ * trail. Submit the configured prompt through the same channel as
116
+ * a typed message so listeners (mountable → chatSession.send) see
117
+ * a uniform shape — no need for a parallel "suggestion-sent" path.
118
+ * The trail's intro pane auto-disappears the moment the first
119
+ * message lands, so this also closes the empty state in one go.
120
+ */
121
+ private _onIntroSuggestion;
122
+ /**
123
+ * Visitor tapped an inline `suggest_replies` chip in the trail. Submit
124
+ * the chip text through the SAME `chat-message-sent` channel a typed
125
+ * message uses, so the reply rides the existing send path (mountable →
126
+ * chatSession.send → transport) — no fabricated AG-UI events. The
127
+ * trail clears the chips on its own once the reply lands and a newer
128
+ * assistant turn becomes the latest.
129
+ */
130
+ private _onSuggestedReply;
131
+ render(): import("lit-html").TemplateResult<1>;
132
+ }
133
+ declare global {
134
+ interface HTMLElementTagNameMap {
135
+ 'adaptive-chat-bar': AdaptiveChatBar;
136
+ }
137
+ }
138
+ //# source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AiBvB;IAEO,MAAM;CAgDhB;AA4PD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,mBAAmB,EAAE,eAAe,CAAC;KACtC;CACF"}
@@ -0,0 +1,11 @@
1
+ import {
2
+ AdaptiveChatBar
3
+ } from "./chunk-VGKCEO6P.js";
4
+ import "./chunk-EWPPVPJ4.js";
5
+ import "./chunk-OV6WQZ5F.js";
6
+ import "./chunk-5PW6T3QF.js";
7
+ import "./chunk-UVKRO5ER.js";
8
+ export {
9
+ AdaptiveChatBar
10
+ };
11
+ //# sourceMappingURL=AdaptiveChatBar.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -0,0 +1,37 @@
1
+ /**
2
+ * AdaptiveChatBarMountable — `MountableWidget` adapter that turns the
3
+ * standalone `<adaptive-chat-bar>` Lit element into something the
4
+ * runtime widget registry can mount.
5
+ *
6
+ * Registered as widget id `adaptive-chatbot:chat-bar`. Customers
7
+ * reference it from canvas config — either as a slot's `lid` widget
8
+ * (replaces the launcher when referenced from `slots.drawer.lid`) or
9
+ * as a regular tile widget.
10
+ *
11
+ * The bar is a VIEW. State lives in the singleton `chatSession` —
12
+ * whether the bar mounts in the mini-canvas lid, the drawer lid, or
13
+ * both, they're all views of the same conversation. The mountable:
14
+ * - subscribes to chatSession.subscribe() and pushes state into
15
+ * the bar's `messages` + `inFlight` props on every change
16
+ * - routes the bar's `chat-message-sent` event → chatSession.send()
17
+ * - routes the bar's `chat-interrupt` event → chatSession.interrupt()
18
+ * - bubbles the bar's `canvas-close` event → optional onClose
19
+ * callback (canvas-level concern, not session-level)
20
+ *
21
+ * Props (passed via mountConfig):
22
+ * - `placeholder?: string` — input placeholder copy
23
+ * - `onClose?: () => void` — fires on ✕ click (canvas-level)
24
+ *
25
+ * Note: messages and inFlight are NOT props. They flow from chatSession.
26
+ * A canvas-config author who wants to pre-seed messages should do so
27
+ * via the session directly (e.g. via a startup action) — but typical
28
+ * use is to let the conversation start empty.
29
+ */
30
+ import './AdaptiveChatBar';
31
+ export declare function resolveTileWidget(templateId: string): string | undefined;
32
+ export declare function refreshTemplateWidgetMap(uiTemplates: Record<string, unknown> | undefined): void;
33
+ export declare const AdaptiveChatBarMountable: {
34
+ mount(container: HTMLElement, mountConfig?: Record<string, unknown>): () => void;
35
+ update(container: HTMLElement, mountConfig?: Record<string, unknown>): void;
36
+ };
37
+ //# sourceMappingURL=AdaptiveChatBarMountable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AdaptiveChatBarMountable.d.ts","sourceRoot":"","sources":["../src/AdaptiveChatBarMountable.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,mBAAmB,CAAC;AA+J3B,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAExE;AAED,wBAAgB,wBAAwB,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GAAG,IAAI,CAgB/F;AA8QD,eAAO,MAAM,wBAAwB;qBAClB,WAAW,gBAAgB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,IAAI;sBAoE9D,WAAW,gBAAgB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;CAQ5E,CAAC"}
@@ -0,0 +1,256 @@
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
+ export declare class AdaptiveChatTrail extends LitElement {
59
+ static styles: import("lit").CSSResult;
60
+ static properties: {
61
+ messages: {
62
+ attribute: boolean;
63
+ };
64
+ visibleCount: {
65
+ type: NumberConstructor;
66
+ };
67
+ expanded: {
68
+ type: BooleanConstructor;
69
+ };
70
+ greeting: {
71
+ type: StringConstructor;
72
+ };
73
+ /** When true: trail renders fully expanded AND the
74
+ * expand/collapse affordance is hidden. Used by hosts that mount
75
+ * the chat in a full-screen surface (the mobile panel) where
76
+ * collapse makes no sense — there's nothing to collapse INTO. */
77
+ forceExpanded: {
78
+ type: BooleanConstructor;
79
+ };
80
+ /**
81
+ * Mirrors `chatSession.inFlight` — true between `send()` and the
82
+ * assistant's first `receiveStart`/`receiveDelta`, OR while a
83
+ * stream is in progress. Drives the "thinking" indicator that
84
+ * fills the gap between the user's just-sent message and the
85
+ * first assistant token. Wired through AdaptiveChatBar (it owns
86
+ * the chatSession subscription and forwards inFlight as a prop).
87
+ */
88
+ inFlight: {
89
+ type: BooleanConstructor;
90
+ };
91
+ /**
92
+ * Live reasoning narration streamed from the model via AG-UI
93
+ * `THINKING_TEXT_MESSAGE_CONTENT`. When non-empty, the thinking
94
+ * chip renders this in place of the bouncing dots so the visitor
95
+ * sees what the model is actually doing instead of staring at
96
+ * silent loading state during a tool-call gap.
97
+ */
98
+ thinkingText: {
99
+ attribute: boolean;
100
+ };
101
+ /**
102
+ * Pre-conversation suggestion chip. When the visitor opens the
103
+ * chat and `messages` is empty, the trail renders this as a
104
+ * button beneath the greeting. Clicking it dispatches a
105
+ * `trail-intro-suggestion` event with the configured prompt —
106
+ * the parent (chat-bar) forwards that to chatSession.send().
107
+ * Disappears the moment the first message lands.
108
+ */
109
+ introSuggestion: {
110
+ attribute: boolean;
111
+ };
112
+ /**
113
+ * Tappable tile-receipt chips rendered once at the end of the
114
+ * trail. Produced from the store by Task 3 (AdaptiveChatBar).
115
+ * Each chip emits `tile-receipt-activate` with its instanceId.
116
+ */
117
+ tileReceipts: {
118
+ attribute: boolean;
119
+ };
120
+ };
121
+ messages: TrailMessage[];
122
+ tileReceipts: TileReceipt[];
123
+ visibleCount: number;
124
+ expanded: boolean;
125
+ forceExpanded: boolean;
126
+ inFlight: boolean;
127
+ thinkingText: string;
128
+ introSuggestion: {
129
+ label: string;
130
+ prompt: string;
131
+ } | undefined;
132
+ /**
133
+ * Pre-conversation phantom assistant message. Rendered only when
134
+ * `messages` is empty. NOT injected into chatSession state — the
135
+ * greeting is configuration, not conversation, so it disappears
136
+ * automatically when the first real message arrives.
137
+ */
138
+ greeting: string | undefined;
139
+ private _onExpand;
140
+ /**
141
+ * Approve a pending client tool call. The trail emits a generic
142
+ * event so the host can decide whether to forward to chatSession
143
+ * (the common path) or override. Keeps the trail itself free of
144
+ * direct chatSession coupling — it's a pure view component.
145
+ */
146
+ private _onToolCallClick;
147
+ private _onCollapse;
148
+ /**
149
+ * Whether to render the thinking-dots chip after the last message.
150
+ * True iff a request is in flight AND the assistant hasn't started
151
+ * streaming a reply yet — once the first delta lands, the streaming
152
+ * chip's caret takes over and the thinking indicator hides so the
153
+ * visitor isn't shown both at once. Also hidden when the last
154
+ * message is an error/system message, because the request that
155
+ * "errored" is already over from the user's perspective.
156
+ */
157
+ private _shouldShowThinking;
158
+ /**
159
+ * instanceId → id of the message that was newest when the receipt first
160
+ * appeared. This is what makes a receipt read like a chat bubble: it renders
161
+ * inline right after its anchor message, so newer messages push it up into
162
+ * history instead of it staying pinned below everything. Assigned once per
163
+ * instanceId (in willUpdate, the only place that sees both `messages` and
164
+ * `tileReceipts` at the moment a tile mounts) and never re-homed — a
165
+ * dismiss/bring-back keeps the chip where it was created. `null` = the tile
166
+ * mounted before the first chat message (canvas replay); those fall to the
167
+ * tail strip (see render).
168
+ */
169
+ private readonly _receiptAnchors;
170
+ willUpdate(changed: Map<string, unknown>): void;
171
+ updated(changed: Map<string, unknown>): void;
172
+ private _onTileReceiptClick;
173
+ private _onAlertReceiptClick;
174
+ /** A row of receipt chips, used at every trail render site (inline per
175
+ * anchor message, the tail fallback, and the empty-state branches) so the
176
+ * markup + styling can never diverge. Returns `nothing` for an empty list. */
177
+ private _renderReceiptStrip;
178
+ /** One receipt chip — a single, unified, single-line design for both kinds
179
+ * (nav "alert" + mounted "tile"). Same container/title/action style so they
180
+ * read as one chip family; the icon + action label carry the kind. No
181
+ * subtitle: the old "Brought up earlier" line was hardcoded (wrong for
182
+ * same-turn mounts) and made the chip taller — dropping it is the "shorter"
183
+ * chip. Rendered at every trail site so the kinds can't diverge. */
184
+ private _renderReceiptChip;
185
+ private _onIntroSuggestionClick;
186
+ /**
187
+ * Visitor tapped a `suggest_replies` inline chip. Emit
188
+ * `trail-suggested-reply` carrying the chip text — the parent
189
+ * (AdaptiveChatBar) re-dispatches it as `chat-message-sent`, the
190
+ * SAME channel the input row uses, so the reply rides the existing
191
+ * send path (mountable → chatSession.send → transport). No fabricated
192
+ * AG-UI events; this is exactly what typing the text and hitting
193
+ * Enter would do. The chips clear on their own once the reply lands
194
+ * and a newer assistant message becomes the latest.
195
+ */
196
+ private _onSuggestedReplyClick;
197
+ render(): typeof nothing | import("lit-html").TemplateResult<1>;
198
+ }
199
+ /**
200
+ * Discriminated visual state for a chip. Replaces the older
201
+ * `(role, { isStreaming, isError })` triple whose interaction order
202
+ * could produce nonsense combinations (e.g. an assistant chip
203
+ * accidentally reading as a user bubble because `isStreaming` was
204
+ * checked before role). Each kind below is a real conversational
205
+ * state with a single visual identity:
206
+ *
207
+ * - `settled` — a complete message; the user-vs-assistant
208
+ * identity comes from `role`
209
+ * - `streaming` — the assistant chip currently receiving tokens;
210
+ * keeps assistant identity (the blinking caret
211
+ * inside the chip carries "in progress")
212
+ * - `pending` — the thinking chip shown between the user's
213
+ * just-sent message and the assistant's first
214
+ * token; assistant identity (the bouncing dots
215
+ * inside carry "in progress")
216
+ * - `error` — a chip whose stream failed mid-flight, OR any
217
+ * system-role message (system messages render
218
+ * with the error identity by convention)
219
+ *
220
+ * Bug history: an earlier branch-ladder design checked `isStreaming`
221
+ * before `role`, so the `pending`/thinking chip inherited the user
222
+ * bubble border. On hosts whose chat panel sits over a light surface
223
+ * that read as a "white div" pasted into the assistant slot. The
224
+ * discriminated state prevents that combination from being expressible.
225
+ */
226
+ export type ChipVisualState = {
227
+ kind: 'settled';
228
+ role: 'user' | 'assistant' | 'system';
229
+ } | {
230
+ kind: 'streaming';
231
+ } | {
232
+ kind: 'pending';
233
+ } | {
234
+ kind: 'error';
235
+ role: 'user' | 'assistant' | 'system';
236
+ };
237
+ /**
238
+ * A misbehaving model can emit a raw SERIALIZED response payload as plain TEXT
239
+ * on a spurious trailing turn — e.g.
240
+ * `(Empty response: {'content': [{'type': 'thinking', …}], 'stop_reason': …})`.
241
+ * Backstop for model degeneration (Kimi); the prompt (S-14) also asks for one
242
+ * brief closing, but copy can't be trusted on the very turn that degenerates.
243
+ *
244
+ * Detection avoids false positives (which are WORSE than the dump — the visitor
245
+ * would see nothing): a turn is dropped only if it OPENS with the literal
246
+ * "(Empty response" marker, OR it carries ≥2 serialization tokens at once. A
247
+ * single token (a product about a "signature blend", the agent quoting one JSON
248
+ * key) never trips it; a real response dump carries all of them.
249
+ */
250
+ export declare function looksLikeSerializedModelResponse(text: string): boolean;
251
+ declare global {
252
+ interface HTMLElementTagNameMap {
253
+ 'adaptive-chat-trail': AdaptiveChatTrail;
254
+ }
255
+ }
256
+ //# 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,6EAA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atTrail,
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
+ }