@syntrologie/adapt-chatbot 2.8.0-canary.42 → 2.8.0-canary.421
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.
- package/dist/AdaptiveChatBar.d.ts +175 -0
- package/dist/AdaptiveChatBar.d.ts.map +1 -0
- package/dist/AdaptiveChatBar.js +11 -0
- package/dist/AdaptiveChatBar.js.map +7 -0
- package/dist/AdaptiveChatBarMountable.d.ts +45 -0
- package/dist/AdaptiveChatBarMountable.d.ts.map +1 -0
- package/dist/AdaptiveChatTrail.anchor-scroll.test.d.ts +2 -0
- package/dist/AdaptiveChatTrail.anchor-scroll.test.d.ts.map +1 -0
- package/dist/AdaptiveChatTrail.d.ts +402 -0
- package/dist/AdaptiveChatTrail.d.ts.map +1 -0
- package/dist/AdaptiveChatTrail.js +11 -0
- package/dist/AdaptiveChatTrail.js.map +7 -0
- package/dist/AdaptiveChatTrail.test.d.ts +2 -0
- package/dist/AdaptiveChatTrail.test.d.ts.map +1 -0
- package/dist/AdaptiveChipsStrip.d.ts +1150 -0
- package/dist/AdaptiveChipsStrip.d.ts.map +1 -0
- package/dist/AdaptiveChipsStrip.js +11 -0
- package/dist/AdaptiveChipsStrip.js.map +7 -0
- package/dist/AdaptiveChipsStripMountable.d.ts +24 -0
- package/dist/AdaptiveChipsStripMountable.d.ts.map +1 -0
- package/dist/ChatAssistantLit.d.ts +60 -0
- package/dist/ChatAssistantLit.d.ts.map +1 -0
- package/dist/ChatAssistantLit.js +13 -0
- package/dist/ChatAssistantLit.js.map +7 -0
- package/dist/ChatSession.d.ts +217 -0
- package/dist/ChatSession.d.ts.map +1 -0
- package/dist/ChatTransport.d.ts +320 -0
- package/dist/ChatTransport.d.ts.map +1 -0
- package/dist/InlineRegistryWidgetMount.test.d.ts +2 -0
- package/dist/InlineRegistryWidgetMount.test.d.ts.map +1 -0
- package/dist/InlineWidgetLiveMount.test.d.ts +2 -0
- package/dist/InlineWidgetLiveMount.test.d.ts.map +1 -0
- package/dist/NavLinkMountable.d.ts +25 -0
- package/dist/NavLinkMountable.d.ts.map +1 -0
- package/dist/NavLinkMountable.test.d.ts +2 -0
- package/dist/NavLinkMountable.test.d.ts.map +1 -0
- package/dist/TextAnswerMountable.d.ts +17 -0
- package/dist/TextAnswerMountable.d.ts.map +1 -0
- package/dist/Turnstile.d.ts +83 -0
- package/dist/Turnstile.d.ts.map +1 -0
- package/dist/cdn.d.ts +2 -6
- package/dist/cdn.d.ts.map +1 -1
- package/dist/chunk-5W75LR6M.js +460 -0
- package/dist/chunk-5W75LR6M.js.map +7 -0
- package/dist/chunk-CHYQU3KP.js +634 -0
- package/dist/chunk-CHYQU3KP.js.map +7 -0
- package/dist/chunk-CWRCHWWJ.js +8958 -0
- package/dist/chunk-CWRCHWWJ.js.map +7 -0
- package/dist/chunk-EWPPVPJ4.js +14 -0
- package/dist/chunk-EWPPVPJ4.js.map +7 -0
- package/dist/chunk-KPWW7N27.js +235 -0
- package/dist/chunk-KPWW7N27.js.map +7 -0
- package/dist/chunk-LSJFN2BR.js +1503 -0
- package/dist/chunk-LSJFN2BR.js.map +7 -0
- package/dist/chunk-QF7ZTKXA.js +3823 -0
- package/dist/chunk-QF7ZTKXA.js.map +7 -0
- package/dist/chunk-UVKRO5ER.js +13 -0
- package/dist/chunk-UVKRO5ER.js.map +7 -0
- package/dist/editor-lit.d.ts +37 -0
- package/dist/editor-lit.d.ts.map +1 -0
- package/dist/editor-lit.js +134 -0
- package/dist/editor-lit.js.map +7 -0
- package/dist/elements/ActionHandler.d.ts +34 -0
- package/dist/elements/ActionHandler.d.ts.map +1 -0
- package/dist/elements/ElementInstanceStore.d.ts +207 -0
- package/dist/elements/ElementInstanceStore.d.ts.map +1 -0
- package/dist/elements/ElementInstanceStore.test.d.ts +2 -0
- package/dist/elements/ElementInstanceStore.test.d.ts.map +1 -0
- package/dist/elements/ElementTypeHandler.d.ts +77 -0
- package/dist/elements/ElementTypeHandler.d.ts.map +1 -0
- package/dist/elements/ItemHandler.d.ts +60 -0
- package/dist/elements/ItemHandler.d.ts.map +1 -0
- package/dist/elements/ItemHandler.test.d.ts +2 -0
- package/dist/elements/ItemHandler.test.d.ts.map +1 -0
- package/dist/elements/TileHandler.d.ts +52 -0
- package/dist/elements/TileHandler.d.ts.map +1 -0
- package/dist/elements/TileHandler.test.d.ts +2 -0
- package/dist/elements/TileHandler.test.d.ts.map +1 -0
- package/dist/elements/__tests__/ElementInstanceStore.recall.test.d.ts +2 -0
- package/dist/elements/__tests__/ElementInstanceStore.recall.test.d.ts.map +1 -0
- package/dist/elements/blockRenderer.d.ts +46 -0
- package/dist/elements/blockRenderer.d.ts.map +1 -0
- package/dist/elements/blockRenderer.test.d.ts +13 -0
- package/dist/elements/blockRenderer.test.d.ts.map +1 -0
- package/dist/elements/blocks.d.ts +58 -0
- package/dist/elements/blocks.d.ts.map +1 -0
- package/dist/elements/envelope.d.ts +24 -0
- package/dist/elements/envelope.d.ts.map +1 -0
- package/dist/elements/fetcher.d.ts +40 -0
- package/dist/elements/fetcher.d.ts.map +1 -0
- package/dist/elements/index.d.ts +33 -0
- package/dist/elements/index.d.ts.map +1 -0
- package/dist/elements/store-singleton.d.ts +4 -0
- package/dist/elements/store-singleton.d.ts.map +1 -0
- package/dist/elements/types.d.ts +106 -0
- package/dist/elements/types.d.ts.map +1 -0
- package/dist/observer/__tests__/allowlist.test.d.ts +9 -0
- package/dist/observer/__tests__/allowlist.test.d.ts.map +1 -0
- package/dist/observer/__tests__/bus-translate.test.d.ts +16 -0
- package/dist/observer/__tests__/bus-translate.test.d.ts.map +1 -0
- package/dist/observer/__tests__/observer-enrich.test.d.ts +10 -0
- package/dist/observer/__tests__/observer-enrich.test.d.ts.map +1 -0
- package/dist/observer/__tests__/observer-isolation.test.d.ts +13 -0
- package/dist/observer/__tests__/observer-isolation.test.d.ts.map +1 -0
- package/dist/observer/__tests__/queue.test.d.ts +2 -0
- package/dist/observer/__tests__/queue.test.d.ts.map +1 -0
- package/dist/observer/__tests__/transport.test.d.ts +2 -0
- package/dist/observer/__tests__/transport.test.d.ts.map +1 -0
- package/dist/observer/allowlist.d.ts +30 -0
- package/dist/observer/allowlist.d.ts.map +1 -0
- package/dist/observer/bus-translate.d.ts +33 -0
- package/dist/observer/bus-translate.d.ts.map +1 -0
- package/dist/observer/index.d.ts +44 -0
- package/dist/observer/index.d.ts.map +1 -0
- package/dist/observer/queue.d.ts +57 -0
- package/dist/observer/queue.d.ts.map +1 -0
- package/dist/observer/transport.d.ts +27 -0
- package/dist/observer/transport.d.ts.map +1 -0
- package/dist/runtime-lit.d.ts +8 -0
- package/dist/runtime-lit.d.ts.map +1 -0
- package/dist/runtime.d.ts +10 -3
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +1909 -29
- package/dist/runtime.js.map +7 -0
- package/dist/schema.d.ts +3340 -11
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +220 -31
- package/dist/schema.js.map +7 -0
- package/dist/test/setup.d.ts +1 -0
- package/dist/test/setup.d.ts.map +1 -0
- package/dist/types.d.ts +61 -40
- package/dist/types.d.ts.map +1 -1
- package/package.json +44 -23
- package/dist/ChatAssistant.d.ts +0 -18
- package/dist/ChatAssistant.d.ts.map +0 -1
- package/dist/ChatAssistant.js +0 -178
- package/dist/SyntroChatbot.d.ts +0 -14
- package/dist/SyntroChatbot.d.ts.map +0 -1
- package/dist/SyntroChatbot.js +0 -56
- package/dist/actionParser.d.ts +0 -15
- package/dist/actionParser.d.ts.map +0 -1
- package/dist/actionParser.js +0 -52
- package/dist/apiClient.d.ts +0 -23
- package/dist/apiClient.d.ts.map +0 -1
- package/dist/apiClient.js +0 -51
- package/dist/cdn.js +0 -37
- package/dist/editor.d.ts +0 -17
- package/dist/editor.d.ts.map +0 -1
- package/dist/editor.js +0 -36
- package/dist/tools/bridge.d.ts +0 -26
- package/dist/tools/bridge.d.ts.map +0 -1
- package/dist/tools/bridge.js +0 -25
- package/dist/tools/expanders.d.ts +0 -17
- package/dist/tools/expanders.d.ts.map +0 -1
- package/dist/tools/expanders.js +0 -41
- package/dist/tools/index.d.ts +0 -14
- package/dist/tools/index.d.ts.map +0 -1
- package/dist/tools/index.js +0 -11
- package/dist/tools/registrations/GetContextTool.d.ts +0 -7
- package/dist/tools/registrations/GetContextTool.d.ts.map +0 -1
- package/dist/tools/registrations/GetContextTool.js +0 -18
- package/dist/tools/registrations/ScrollToTool.d.ts +0 -7
- package/dist/tools/registrations/ScrollToTool.d.ts.map +0 -1
- package/dist/tools/registrations/ScrollToTool.js +0 -38
- package/dist/tools/registrations/ShowOverlayTool.d.ts +0 -7
- package/dist/tools/registrations/ShowOverlayTool.d.ts.map +0 -1
- package/dist/tools/registrations/ShowOverlayTool.js +0 -47
- package/dist/tools/registrations/index.d.ts +0 -19
- package/dist/tools/registrations/index.d.ts.map +0 -1
- package/dist/tools/registrations/index.js +0 -7
- package/dist/types.js +0 -6
- package/dist/useChat.d.ts +0 -25
- package/dist/useChat.d.ts.map +0 -1
- package/dist/useChat.js +0 -106
|
@@ -0,0 +1,175 @@
|
|
|
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 { InlineTrailWidget, InlineWidgetMounter, 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
|
+
assistantName: {
|
|
33
|
+
type: StringConstructor;
|
|
34
|
+
};
|
|
35
|
+
greeting: {
|
|
36
|
+
type: StringConstructor;
|
|
37
|
+
};
|
|
38
|
+
inFlight: {
|
|
39
|
+
type: BooleanConstructor;
|
|
40
|
+
reflect: boolean;
|
|
41
|
+
};
|
|
42
|
+
thinkingText: {
|
|
43
|
+
attribute: boolean;
|
|
44
|
+
};
|
|
45
|
+
introSuggestion: {
|
|
46
|
+
attribute: boolean;
|
|
47
|
+
};
|
|
48
|
+
forceExpanded: {
|
|
49
|
+
type: BooleanConstructor;
|
|
50
|
+
reflect: boolean;
|
|
51
|
+
};
|
|
52
|
+
maximized: {
|
|
53
|
+
type: BooleanConstructor;
|
|
54
|
+
};
|
|
55
|
+
tileReceipts: {
|
|
56
|
+
attribute: boolean;
|
|
57
|
+
};
|
|
58
|
+
inlineWidgets: {
|
|
59
|
+
attribute: boolean;
|
|
60
|
+
};
|
|
61
|
+
mountInlineWidget: {
|
|
62
|
+
attribute: boolean;
|
|
63
|
+
};
|
|
64
|
+
_input: {
|
|
65
|
+
state: boolean;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
messages: TrailMessage[];
|
|
69
|
+
maximized: boolean;
|
|
70
|
+
tileReceipts: TileReceipt[];
|
|
71
|
+
/** Widgets rendered inline in the trail (reco carousel), sourced from
|
|
72
|
+
* the store's `chat-inline` slot mounts. Forwarded to the trail. */
|
|
73
|
+
inlineWidgets: InlineTrailWidget[];
|
|
74
|
+
/** Registry-backed mounter for inline widgets whose id is not their
|
|
75
|
+
* custom-element tag (product card, comparison, FAQ). Set by the
|
|
76
|
+
* mountable from `runtime.widgets`; forwarded to the trail. */
|
|
77
|
+
mountInlineWidget: InlineWidgetMounter | undefined;
|
|
78
|
+
/**
|
|
79
|
+
* Live reasoning narration from the model — streamed in via
|
|
80
|
+
* AG-UI THINKING_TEXT_MESSAGE_CONTENT events and forwarded by
|
|
81
|
+
* the ChatSession subscription on the host (mountable).
|
|
82
|
+
* Forwarded verbatim to the trail, which renders it in place of
|
|
83
|
+
* the silent loading dots between turns. Empty string when no
|
|
84
|
+
* thinking turn is active.
|
|
85
|
+
*/
|
|
86
|
+
thinkingText: string;
|
|
87
|
+
/**
|
|
88
|
+
* Pre-conversation suggestion button — forwarded to the trail's
|
|
89
|
+
* empty-state pane. When the visitor clicks it the trail emits
|
|
90
|
+
* `trail-intro-suggestion`; we catch that here and submit the
|
|
91
|
+
* configured prompt through the normal send path.
|
|
92
|
+
*/
|
|
93
|
+
introSuggestion: {
|
|
94
|
+
label: string;
|
|
95
|
+
prompt: string;
|
|
96
|
+
} | undefined;
|
|
97
|
+
/** Pass-through to {@link AdaptiveChatTrail}'s ``forceExpanded`` prop.
|
|
98
|
+
* Hosts that mount the chat-bar in a full-screen surface (mobile
|
|
99
|
+
* panel, agent app, etc.) set this to skip the collapse affordance
|
|
100
|
+
* — there is no smaller state to fall back to. */
|
|
101
|
+
forceExpanded: boolean;
|
|
102
|
+
placeholder: string;
|
|
103
|
+
/**
|
|
104
|
+
* Name shown in the (forceExpanded) header. Defaults to a generic
|
|
105
|
+
* "Assistant". Hosts can override per-workspace (e.g. Vela sets
|
|
106
|
+
* "Vela Concierge") without inventing new SDK surface — it threads
|
|
107
|
+
* through the same mount config the placeholder does.
|
|
108
|
+
*/
|
|
109
|
+
assistantName: string;
|
|
110
|
+
/**
|
|
111
|
+
* Initial assistant message shown before any real conversation
|
|
112
|
+
* starts. Renders inside the trail as a phantom assistant chip
|
|
113
|
+
* when messages.length === 0; auto-disappears as soon as the
|
|
114
|
+
* first user message lands. Mirrors ChatAssistantLit's greeting.
|
|
115
|
+
*/
|
|
116
|
+
greeting: string | undefined;
|
|
117
|
+
/**
|
|
118
|
+
* Whether a chat round-trip is in flight (request sent, awaiting
|
|
119
|
+
* reply). The single send/stop button morphs accordingly: ↑ when
|
|
120
|
+
* ready, ⏹ when in-flight. Parent owns this state — set true after
|
|
121
|
+
* `chat-message-sent` fires, false when the reply lands or the
|
|
122
|
+
* request is aborted. Enter is inert while in-flight.
|
|
123
|
+
*/
|
|
124
|
+
inFlight: boolean;
|
|
125
|
+
_input: string;
|
|
126
|
+
createRenderRoot(): HTMLElement;
|
|
127
|
+
connectedCallback(): void;
|
|
128
|
+
disconnectedCallback(): void;
|
|
129
|
+
private _onInput;
|
|
130
|
+
private _onKeyDown;
|
|
131
|
+
private _onSendOrInterrupt;
|
|
132
|
+
private _onTileReceiptActivate;
|
|
133
|
+
private _onAlertReceiptActivate;
|
|
134
|
+
private _onMaximizeToggle;
|
|
135
|
+
private _send;
|
|
136
|
+
/**
|
|
137
|
+
* Visitor tapped the intro suggestion button in the empty-state
|
|
138
|
+
* trail. Submit the configured prompt through the same channel as
|
|
139
|
+
* a typed message so listeners (mountable → chatSession.send) see
|
|
140
|
+
* a uniform shape — no need for a parallel "suggestion-sent" path.
|
|
141
|
+
* The trail's intro pane auto-disappears the moment the first
|
|
142
|
+
* message lands, so this also closes the empty state in one go.
|
|
143
|
+
*/
|
|
144
|
+
private _onIntroSuggestion;
|
|
145
|
+
/**
|
|
146
|
+
* Reply-chip tap that arrived during the run TAIL. Chips render the
|
|
147
|
+
* moment the reply text lands, but `inFlight` (which includes
|
|
148
|
+
* `runActive` — typing events, tool tail, RUN_FINISHED) can lag for
|
|
149
|
+
* seconds. The old `if (this.inFlight) return;` guard silently ATE
|
|
150
|
+
* those taps — the visitor's chosen reply never appeared as their
|
|
151
|
+
* message (live repro, deployed vela 2026-07-08). Now the tap queues
|
|
152
|
+
* (latest wins) and dispatches when `inFlight` clears.
|
|
153
|
+
*/
|
|
154
|
+
private _queuedSuggestedReply;
|
|
155
|
+
protected willUpdate(changed: Map<string, unknown>): void;
|
|
156
|
+
/**
|
|
157
|
+
* Visitor tapped an inline `suggest_replies` chip in the trail. Submit
|
|
158
|
+
* the chip text through the SAME `chat-message-sent` channel a typed
|
|
159
|
+
* message uses, so the reply rides the existing send path (mountable →
|
|
160
|
+
* chatSession.send → transport) — no fabricated AG-UI events. The
|
|
161
|
+
* trail clears the chips on its own once the reply lands and a newer
|
|
162
|
+
* assistant turn becomes the latest.
|
|
163
|
+
*
|
|
164
|
+
* A tap while the previous run is still closing is QUEUED, never
|
|
165
|
+
* dropped — see `_queuedSuggestedReply`.
|
|
166
|
+
*/
|
|
167
|
+
private _onSuggestedReply;
|
|
168
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
169
|
+
}
|
|
170
|
+
declare global {
|
|
171
|
+
interface HTMLElementTagNameMap {
|
|
172
|
+
'adaptive-chat-bar': AdaptiveChatBar;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
//# sourceMappingURL=AdaptiveChatBar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AdaptiveChatBar.d.ts","sourceRoot":"","sources":["../src/AdaptiveChatBar.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAQ,UAAU,EAAW,MAAM,KAAK,CAAC;AAGhD,OAAO,wBAAwB,CAAC;AAChC,OAAO,KAAK,EACV,iBAAiB,EACjB,mBAAmB,EACnB,WAAW,EACX,YAAY,EACb,MAAM,wBAAwB,CAAC;AAMhC,qBAAa,eAAgB,SAAQ,UAAU;IAC7C,OAAgB,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MA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"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AdaptiveChatBar
|
|
3
|
+
} from "./chunk-5W75LR6M.js";
|
|
4
|
+
import "./chunk-EWPPVPJ4.js";
|
|
5
|
+
import "./chunk-LSJFN2BR.js";
|
|
6
|
+
import "./chunk-QF7ZTKXA.js";
|
|
7
|
+
import "./chunk-UVKRO5ER.js";
|
|
8
|
+
export {
|
|
9
|
+
AdaptiveChatBar
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=AdaptiveChatBar.js.map
|
|
@@ -0,0 +1,45 @@
|
|
|
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
|
+
/**
|
|
32
|
+
* Test-only: drop the warm store singleton (and its hydration latch) so each
|
|
33
|
+
* test can wire a fresh store to its own event bus / registry. Without this,
|
|
34
|
+
* the first test in a file permanently binds the store to ITS bus and the
|
|
35
|
+
* per-instance version dedup silently drops every later test's re-mounts.
|
|
36
|
+
* Mirrors `observer/index.ts` `_resetObserverForTests`.
|
|
37
|
+
*/
|
|
38
|
+
export declare function _resetElementStoreForTests(): void;
|
|
39
|
+
export declare function resolveTileWidget(templateId: string): string | undefined;
|
|
40
|
+
export declare function refreshTemplateWidgetMap(uiTemplates: Record<string, unknown> | undefined): void;
|
|
41
|
+
export declare const AdaptiveChatBarMountable: {
|
|
42
|
+
mount(container: HTMLElement, mountConfig?: Record<string, unknown>): () => void;
|
|
43
|
+
update(container: HTMLElement, mountConfig?: Record<string, unknown>): void;
|
|
44
|
+
};
|
|
45
|
+
//# 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;AAoJ3B;;;;;;GAMG;AACH,wBAAgB,0BAA0B,IAAI,IAAI,CAIjD;AA6BD,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;AA0SD,eAAO,MAAM,wBAAwB;qBAClB,WAAW,gBAAgB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,IAAI;sBA2F9D,WAAW,gBAAgB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;CAQ5E,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AdaptiveChatTrail.anchor-scroll.test.d.ts","sourceRoot":"","sources":["../src/AdaptiveChatTrail.anchor-scroll.test.ts"],"names":[],"mappings":"AA0BA,OAAO,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,402 @@
|
|
|
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
|
+
willUpdate(changed: Map<string, unknown>): void;
|
|
289
|
+
/**
|
|
290
|
+
* Create (once) or refresh the cached element for an inline widget.
|
|
291
|
+
*
|
|
292
|
+
* Two mount paths, both keeping the chat bundle free of any widget-package
|
|
293
|
+
* import:
|
|
294
|
+
* - Direct tag (self-defining, server-mounted widgets like the reco
|
|
295
|
+
* carousel whose declared `widget` IS its custom-element tag):
|
|
296
|
+
* `document.createElement(tag)`.
|
|
297
|
+
* - Widget-id (admin-template widgets like `adaptive-product:card` or
|
|
298
|
+
* `adaptive-faq:accordion`, whose `widget` is a runtime widget-id, NOT a
|
|
299
|
+
* valid custom-element tag): mount through the runtime widget registry
|
|
300
|
+
* via {@link mountInlineWidget}, which resolves the id to its real
|
|
301
|
+
* element exactly like the deck `SyntroTileCard` path. Without this,
|
|
302
|
+
* `createElement('adaptive-product:card')` yields an inert unknown
|
|
303
|
+
* element and the tile renders permanently blank (the "inline mode
|
|
304
|
+
* shows nothing but the reco" bug).
|
|
305
|
+
*
|
|
306
|
+
* Fail-safe: an id that resolves to neither a defined tag nor a registered
|
|
307
|
+
* widget caches `null` and renders nothing (no broken box).
|
|
308
|
+
*/
|
|
309
|
+
private _ensureInlineElement;
|
|
310
|
+
updated(changed: Map<string, unknown>): void;
|
|
311
|
+
private _onTileReceiptClick;
|
|
312
|
+
private _onAlertReceiptClick;
|
|
313
|
+
/** Render a set of inline widgets (reco carousel etc.) as
|
|
314
|
+
* `[data-trail-widget]` blocks, anchored to a message position like
|
|
315
|
+
* receipts. Each block hosts the cached custom element for that
|
|
316
|
+
* instanceId — a defined tag mounts inline; an undefined tag renders
|
|
317
|
+
* nothing (fail-safe). Rendered at every trail site (inline per anchor,
|
|
318
|
+
* tail, empty-state) so placement can't diverge. */
|
|
319
|
+
private _renderInlineWidgetStrip;
|
|
320
|
+
/** A row of receipt chips, used at every trail render site (inline per
|
|
321
|
+
* anchor message, the tail fallback, and the empty-state branches) so the
|
|
322
|
+
* markup + styling can never diverge. Returns `nothing` for an empty list. */
|
|
323
|
+
private _renderReceiptStrip;
|
|
324
|
+
/** One receipt chip — a single, unified, single-line design for both kinds
|
|
325
|
+
* (nav "alert" + mounted "tile"). Same container/title/action style so they
|
|
326
|
+
* read as one chip family; the icon + action label carry the kind. No
|
|
327
|
+
* subtitle: the old "Brought up earlier" line was hardcoded (wrong for
|
|
328
|
+
* same-turn mounts) and made the chip taller — dropping it is the "shorter"
|
|
329
|
+
* chip. Rendered at every trail site so the kinds can't diverge. */
|
|
330
|
+
private _renderReceiptChip;
|
|
331
|
+
private _onIntroSuggestionClick;
|
|
332
|
+
/**
|
|
333
|
+
* Visitor tapped a `suggest_replies` inline chip. Emit
|
|
334
|
+
* `trail-suggested-reply` carrying the chip text — the parent
|
|
335
|
+
* (AdaptiveChatBar) re-dispatches it as `chat-message-sent`, the
|
|
336
|
+
* SAME channel the input row uses, so the reply rides the existing
|
|
337
|
+
* send path (mountable → chatSession.send → transport). No fabricated
|
|
338
|
+
* AG-UI events; this is exactly what typing the text and hitting
|
|
339
|
+
* Enter would do. The chips clear on their own once the reply lands
|
|
340
|
+
* and a newer assistant message becomes the latest.
|
|
341
|
+
*/
|
|
342
|
+
private _onSuggestedReplyClick;
|
|
343
|
+
render(): typeof nothing | import("lit-html").TemplateResult<1>;
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Discriminated visual state for a chip. Replaces the older
|
|
347
|
+
* `(role, { isStreaming, isError })` triple whose interaction order
|
|
348
|
+
* could produce nonsense combinations (e.g. an assistant chip
|
|
349
|
+
* accidentally reading as a user bubble because `isStreaming` was
|
|
350
|
+
* checked before role). Each kind below is a real conversational
|
|
351
|
+
* state with a single visual identity:
|
|
352
|
+
*
|
|
353
|
+
* - `settled` — a complete message; the user-vs-assistant
|
|
354
|
+
* identity comes from `role`
|
|
355
|
+
* - `streaming` — the assistant chip currently receiving tokens;
|
|
356
|
+
* keeps assistant identity (the blinking caret
|
|
357
|
+
* inside the chip carries "in progress")
|
|
358
|
+
* - `pending` — the thinking chip shown between the user's
|
|
359
|
+
* just-sent message and the assistant's first
|
|
360
|
+
* token; assistant identity (the bouncing dots
|
|
361
|
+
* inside carry "in progress")
|
|
362
|
+
* - `error` — a chip whose stream failed mid-flight, OR any
|
|
363
|
+
* system-role message (system messages render
|
|
364
|
+
* with the error identity by convention)
|
|
365
|
+
*
|
|
366
|
+
* Bug history: an earlier branch-ladder design checked `isStreaming`
|
|
367
|
+
* before `role`, so the `pending`/thinking chip inherited the user
|
|
368
|
+
* bubble border. On hosts whose chat panel sits over a light surface
|
|
369
|
+
* that read as a "white div" pasted into the assistant slot. The
|
|
370
|
+
* discriminated state prevents that combination from being expressible.
|
|
371
|
+
*/
|
|
372
|
+
export type ChipVisualState = {
|
|
373
|
+
kind: 'settled';
|
|
374
|
+
role: 'user' | 'assistant' | 'system';
|
|
375
|
+
} | {
|
|
376
|
+
kind: 'streaming';
|
|
377
|
+
} | {
|
|
378
|
+
kind: 'pending';
|
|
379
|
+
} | {
|
|
380
|
+
kind: 'error';
|
|
381
|
+
role: 'user' | 'assistant' | 'system';
|
|
382
|
+
};
|
|
383
|
+
/**
|
|
384
|
+
* A misbehaving model can emit a raw SERIALIZED response payload as plain TEXT
|
|
385
|
+
* on a spurious trailing turn — e.g.
|
|
386
|
+
* `(Empty response: {'content': [{'type': 'thinking', …}], 'stop_reason': …})`.
|
|
387
|
+
* Backstop for model degeneration (Kimi); the prompt (S-14) also asks for one
|
|
388
|
+
* brief closing, but copy can't be trusted on the very turn that degenerates.
|
|
389
|
+
*
|
|
390
|
+
* Detection avoids false positives (which are WORSE than the dump — the visitor
|
|
391
|
+
* would see nothing): a turn is dropped only if it OPENS with the literal
|
|
392
|
+
* "(Empty response" marker, OR it carries ≥2 serialization tokens at once. A
|
|
393
|
+
* single token (a product about a "signature blend", the agent quoting one JSON
|
|
394
|
+
* key) never trips it; a real response dump carries all of them.
|
|
395
|
+
*/
|
|
396
|
+
export declare function looksLikeSerializedModelResponse(text: string): boolean;
|
|
397
|
+
declare global {
|
|
398
|
+
interface HTMLElementTagNameMap {
|
|
399
|
+
'adaptive-chat-trail': AdaptiveChatTrail;
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
//# 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;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