@syntrologie/adapt-chatbot 2.8.0-canary.36 → 2.8.0-canary.361
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 +125 -0
- package/dist/AdaptiveChatBar.d.ts.map +1 -0
- package/dist/AdaptiveChatBar.js +10 -0
- package/dist/AdaptiveChatBar.js.map +7 -0
- package/dist/AdaptiveChatBarMountable.d.ts +35 -0
- package/dist/AdaptiveChatBarMountable.d.ts.map +1 -0
- package/dist/AdaptiveChatTrail.d.ts +197 -0
- package/dist/AdaptiveChatTrail.d.ts.map +1 -0
- package/dist/AdaptiveChatTrail.js +9 -0
- package/dist/AdaptiveChatTrail.js.map +7 -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 +12 -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 +311 -0
- package/dist/ChatTransport.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-FVNSOP7B.js +634 -0
- package/dist/chunk-FVNSOP7B.js.map +7 -0
- package/dist/chunk-GS3NMZAU.js +902 -0
- package/dist/chunk-GS3NMZAU.js.map +7 -0
- package/dist/chunk-JMP4WEJR.js +8841 -0
- package/dist/chunk-JMP4WEJR.js.map +7 -0
- package/dist/chunk-LY2A6P2P.js +385 -0
- package/dist/chunk-LY2A6P2P.js.map +7 -0
- package/dist/chunk-ONGGPQER.js +3722 -0
- package/dist/chunk-ONGGPQER.js.map +7 -0
- package/dist/chunk-UVKRO5ER.js +13 -0
- package/dist/chunk-UVKRO5ER.js.map +7 -0
- package/dist/chunk-VLJ3WOEX.js +231 -0
- package/dist/chunk-VLJ3WOEX.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 +155 -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/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 +32 -0
- package/dist/elements/index.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__/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 +32 -0
- package/dist/observer/allowlist.d.ts.map +1 -0
- package/dist/observer/index.d.ts +36 -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 +8 -3
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +1796 -29
- package/dist/runtime.js.map +7 -0
- package/dist/schema.d.ts +3334 -11
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +217 -31
- package/dist/schema.js.map +7 -0
- package/dist/types.d.ts +47 -40
- package/dist/types.d.ts.map +1 -1
- package/package.json +43 -22
- 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 -52
- 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,125 @@
|
|
|
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 { 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
|
+
_input: {
|
|
50
|
+
state: boolean;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
messages: TrailMessage[];
|
|
54
|
+
/**
|
|
55
|
+
* Live reasoning narration from the model — streamed in via
|
|
56
|
+
* AG-UI THINKING_TEXT_MESSAGE_CONTENT events and forwarded by
|
|
57
|
+
* the ChatSession subscription on the host (mountable).
|
|
58
|
+
* Forwarded verbatim to the trail, which renders it in place of
|
|
59
|
+
* the silent loading dots between turns. Empty string when no
|
|
60
|
+
* thinking turn is active.
|
|
61
|
+
*/
|
|
62
|
+
thinkingText: string;
|
|
63
|
+
/**
|
|
64
|
+
* Pre-conversation suggestion button — forwarded to the trail's
|
|
65
|
+
* empty-state pane. When the visitor clicks it the trail emits
|
|
66
|
+
* `trail-intro-suggestion`; we catch that here and submit the
|
|
67
|
+
* configured prompt through the normal send path.
|
|
68
|
+
*/
|
|
69
|
+
introSuggestion: {
|
|
70
|
+
label: string;
|
|
71
|
+
prompt: string;
|
|
72
|
+
} | undefined;
|
|
73
|
+
/** Pass-through to {@link AdaptiveChatTrail}'s ``forceExpanded`` prop.
|
|
74
|
+
* Hosts that mount the chat-bar in a full-screen surface (mobile
|
|
75
|
+
* panel, agent app, etc.) set this to skip the collapse affordance
|
|
76
|
+
* — there is no smaller state to fall back to. */
|
|
77
|
+
forceExpanded: boolean;
|
|
78
|
+
placeholder: string;
|
|
79
|
+
/**
|
|
80
|
+
* Initial assistant message shown before any real conversation
|
|
81
|
+
* starts. Renders inside the trail as a phantom assistant chip
|
|
82
|
+
* when messages.length === 0; auto-disappears as soon as the
|
|
83
|
+
* first user message lands. Mirrors ChatAssistantLit's greeting.
|
|
84
|
+
*/
|
|
85
|
+
greeting: string | undefined;
|
|
86
|
+
/**
|
|
87
|
+
* Whether a chat round-trip is in flight (request sent, awaiting
|
|
88
|
+
* reply). The single send/stop button morphs accordingly: ↑ when
|
|
89
|
+
* ready, ⏹ when in-flight. Parent owns this state — set true after
|
|
90
|
+
* `chat-message-sent` fires, false when the reply lands or the
|
|
91
|
+
* request is aborted. Enter is inert while in-flight.
|
|
92
|
+
*/
|
|
93
|
+
inFlight: boolean;
|
|
94
|
+
_input: string;
|
|
95
|
+
createRenderRoot(): HTMLElement;
|
|
96
|
+
private _onInput;
|
|
97
|
+
private _onKeyDown;
|
|
98
|
+
private _onSendOrInterrupt;
|
|
99
|
+
private _send;
|
|
100
|
+
/**
|
|
101
|
+
* Visitor tapped the intro suggestion button in the empty-state
|
|
102
|
+
* trail. Submit the configured prompt through the same channel as
|
|
103
|
+
* a typed message so listeners (mountable → chatSession.send) see
|
|
104
|
+
* a uniform shape — no need for a parallel "suggestion-sent" path.
|
|
105
|
+
* The trail's intro pane auto-disappears the moment the first
|
|
106
|
+
* message lands, so this also closes the empty state in one go.
|
|
107
|
+
*/
|
|
108
|
+
private _onIntroSuggestion;
|
|
109
|
+
/**
|
|
110
|
+
* Visitor tapped an inline `suggest_replies` chip in the trail. Submit
|
|
111
|
+
* the chip text through the SAME `chat-message-sent` channel a typed
|
|
112
|
+
* message uses, so the reply rides the existing send path (mountable →
|
|
113
|
+
* chatSession.send → transport) — no fabricated AG-UI events. The
|
|
114
|
+
* trail clears the chips on its own once the reply lands and a newer
|
|
115
|
+
* assistant turn becomes the latest.
|
|
116
|
+
*/
|
|
117
|
+
private _onSuggestedReply;
|
|
118
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
119
|
+
}
|
|
120
|
+
declare global {
|
|
121
|
+
interface HTMLElementTagNameMap {
|
|
122
|
+
'adaptive-chat-bar': AdaptiveChatBar;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
//# 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,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAI3D,qBAAa,eAAgB,SAAQ,UAAU;IAC7C,OAAgB,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;MASxB;IAEF,QAAQ,EAAE,YAAY,EAAE,CAAM;IAE9B;;;;;;;OAOG;IACH,YAAY,SAAM;IAClB;;;;;OAKG;IACH,eAAe,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAAa;IAE3E;;;uDAGmD;IACnD,aAAa,UAAS;IACtB,WAAW,SAAuB;IAClC;;;;;OAKG;IACH,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAa;IACzC;;;;;;OAMG;IACH,QAAQ,UAAS;IACjB,MAAM,SAAM;IAEH,gBAAgB,IAAI,WAAW;IAUxC,OAAO,CAAC,QAAQ,CAEd;IAEF,OAAO,CAAC,UAAU,CAShB;IAKF,OAAO,CAAC,kBAAkB,CAMxB;IAEF,OAAO,CAAC,KAAK;IAoBb;;;;;;;OAOG;IACH,OAAO,CAAC,kBAAkB,CAmBxB;IAEF;;;;;;;OAOG;IACH,OAAO,CAAC,iBAAiB,CAiBvB;IAEO,MAAM;CAuChB;AA6OD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,mBAAmB,EAAE,eAAe,CAAC;KACtC;CACF"}
|
|
@@ -0,0 +1,35 @@
|
|
|
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 const AdaptiveChatBarMountable: {
|
|
32
|
+
mount(container: HTMLElement, mountConfig?: Record<string, unknown>): () => void;
|
|
33
|
+
update(container: HTMLElement, mountConfig?: Record<string, unknown>): void;
|
|
34
|
+
};
|
|
35
|
+
//# 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;AAqa3B,eAAO,MAAM,wBAAwB;qBAClB,WAAW,gBAAgB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,IAAI;sBA0C9D,WAAW,gBAAgB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;CAQ5E,CAAC"}
|
|
@@ -0,0 +1,197 @@
|
|
|
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 declare class AdaptiveChatTrail extends LitElement {
|
|
49
|
+
static styles: import("lit").CSSResult;
|
|
50
|
+
static properties: {
|
|
51
|
+
messages: {
|
|
52
|
+
attribute: boolean;
|
|
53
|
+
};
|
|
54
|
+
visibleCount: {
|
|
55
|
+
type: NumberConstructor;
|
|
56
|
+
};
|
|
57
|
+
expanded: {
|
|
58
|
+
type: BooleanConstructor;
|
|
59
|
+
};
|
|
60
|
+
greeting: {
|
|
61
|
+
type: StringConstructor;
|
|
62
|
+
};
|
|
63
|
+
/** When true: trail renders fully expanded AND the
|
|
64
|
+
* expand/collapse affordance is hidden. Used by hosts that mount
|
|
65
|
+
* the chat in a full-screen surface (the mobile panel) where
|
|
66
|
+
* collapse makes no sense — there's nothing to collapse INTO. */
|
|
67
|
+
forceExpanded: {
|
|
68
|
+
type: BooleanConstructor;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Mirrors `chatSession.inFlight` — true between `send()` and the
|
|
72
|
+
* assistant's first `receiveStart`/`receiveDelta`, OR while a
|
|
73
|
+
* stream is in progress. Drives the "thinking" indicator that
|
|
74
|
+
* fills the gap between the user's just-sent message and the
|
|
75
|
+
* first assistant token. Wired through AdaptiveChatBar (it owns
|
|
76
|
+
* the chatSession subscription and forwards inFlight as a prop).
|
|
77
|
+
*/
|
|
78
|
+
inFlight: {
|
|
79
|
+
type: BooleanConstructor;
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Live reasoning narration streamed from the model via AG-UI
|
|
83
|
+
* `THINKING_TEXT_MESSAGE_CONTENT`. When non-empty, the thinking
|
|
84
|
+
* chip renders this in place of the bouncing dots so the visitor
|
|
85
|
+
* sees what the model is actually doing instead of staring at
|
|
86
|
+
* silent loading state during a tool-call gap.
|
|
87
|
+
*/
|
|
88
|
+
thinkingText: {
|
|
89
|
+
attribute: boolean;
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Pre-conversation suggestion chip. When the visitor opens the
|
|
93
|
+
* chat and `messages` is empty, the trail renders this as a
|
|
94
|
+
* button beneath the greeting. Clicking it dispatches a
|
|
95
|
+
* `trail-intro-suggestion` event with the configured prompt —
|
|
96
|
+
* the parent (chat-bar) forwards that to chatSession.send().
|
|
97
|
+
* Disappears the moment the first message lands.
|
|
98
|
+
*/
|
|
99
|
+
introSuggestion: {
|
|
100
|
+
attribute: boolean;
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
messages: TrailMessage[];
|
|
104
|
+
visibleCount: number;
|
|
105
|
+
expanded: boolean;
|
|
106
|
+
forceExpanded: boolean;
|
|
107
|
+
inFlight: boolean;
|
|
108
|
+
thinkingText: string;
|
|
109
|
+
introSuggestion: {
|
|
110
|
+
label: string;
|
|
111
|
+
prompt: string;
|
|
112
|
+
} | undefined;
|
|
113
|
+
/**
|
|
114
|
+
* Pre-conversation phantom assistant message. Rendered only when
|
|
115
|
+
* `messages` is empty. NOT injected into chatSession state — the
|
|
116
|
+
* greeting is configuration, not conversation, so it disappears
|
|
117
|
+
* automatically when the first real message arrives.
|
|
118
|
+
*/
|
|
119
|
+
greeting: string | undefined;
|
|
120
|
+
private _onExpand;
|
|
121
|
+
/**
|
|
122
|
+
* Approve a pending client tool call. The trail emits a generic
|
|
123
|
+
* event so the host can decide whether to forward to chatSession
|
|
124
|
+
* (the common path) or override. Keeps the trail itself free of
|
|
125
|
+
* direct chatSession coupling — it's a pure view component.
|
|
126
|
+
*/
|
|
127
|
+
private _onToolCallClick;
|
|
128
|
+
private _onCollapse;
|
|
129
|
+
/**
|
|
130
|
+
* Whether to render the thinking-dots chip after the last message.
|
|
131
|
+
* True iff a request is in flight AND the assistant hasn't started
|
|
132
|
+
* streaming a reply yet — once the first delta lands, the streaming
|
|
133
|
+
* chip's caret takes over and the thinking indicator hides so the
|
|
134
|
+
* visitor isn't shown both at once. Also hidden when the last
|
|
135
|
+
* message is an error/system message, because the request that
|
|
136
|
+
* "errored" is already over from the user's perspective.
|
|
137
|
+
*/
|
|
138
|
+
private _shouldShowThinking;
|
|
139
|
+
updated(changed: Map<string, unknown>): void;
|
|
140
|
+
private _onIntroSuggestionClick;
|
|
141
|
+
/**
|
|
142
|
+
* Visitor tapped a `suggest_replies` inline chip. Emit
|
|
143
|
+
* `trail-suggested-reply` carrying the chip text — the parent
|
|
144
|
+
* (AdaptiveChatBar) re-dispatches it as `chat-message-sent`, the
|
|
145
|
+
* SAME channel the input row uses, so the reply rides the existing
|
|
146
|
+
* send path (mountable → chatSession.send → transport). No fabricated
|
|
147
|
+
* AG-UI events; this is exactly what typing the text and hitting
|
|
148
|
+
* Enter would do. The chips clear on their own once the reply lands
|
|
149
|
+
* and a newer assistant message becomes the latest.
|
|
150
|
+
*/
|
|
151
|
+
private _onSuggestedReplyClick;
|
|
152
|
+
render(): typeof nothing | import("lit-html").TemplateResult<1>;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Discriminated visual state for a chip. Replaces the older
|
|
156
|
+
* `(role, { isStreaming, isError })` triple whose interaction order
|
|
157
|
+
* could produce nonsense combinations (e.g. an assistant chip
|
|
158
|
+
* accidentally reading as a user bubble because `isStreaming` was
|
|
159
|
+
* checked before role). Each kind below is a real conversational
|
|
160
|
+
* state with a single visual identity:
|
|
161
|
+
*
|
|
162
|
+
* - `settled` — a complete message; the user-vs-assistant
|
|
163
|
+
* identity comes from `role`
|
|
164
|
+
* - `streaming` — the assistant chip currently receiving tokens;
|
|
165
|
+
* keeps assistant identity (the blinking caret
|
|
166
|
+
* inside the chip carries "in progress")
|
|
167
|
+
* - `pending` — the thinking chip shown between the user's
|
|
168
|
+
* just-sent message and the assistant's first
|
|
169
|
+
* token; assistant identity (the bouncing dots
|
|
170
|
+
* inside carry "in progress")
|
|
171
|
+
* - `error` — a chip whose stream failed mid-flight, OR any
|
|
172
|
+
* system-role message (system messages render
|
|
173
|
+
* with the error identity by convention)
|
|
174
|
+
*
|
|
175
|
+
* Bug history: an earlier branch-ladder design checked `isStreaming`
|
|
176
|
+
* before `role`, so the `pending`/thinking chip inherited the user
|
|
177
|
+
* bubble border. On hosts whose chat panel sits over a light surface
|
|
178
|
+
* that read as a "white div" pasted into the assistant slot. The
|
|
179
|
+
* discriminated state prevents that combination from being expressible.
|
|
180
|
+
*/
|
|
181
|
+
export type ChipVisualState = {
|
|
182
|
+
kind: 'settled';
|
|
183
|
+
role: 'user' | 'assistant' | 'system';
|
|
184
|
+
} | {
|
|
185
|
+
kind: 'streaming';
|
|
186
|
+
} | {
|
|
187
|
+
kind: 'pending';
|
|
188
|
+
} | {
|
|
189
|
+
kind: 'error';
|
|
190
|
+
role: 'user' | 'assistant' | 'system';
|
|
191
|
+
};
|
|
192
|
+
declare global {
|
|
193
|
+
interface HTMLElementTagNameMap {
|
|
194
|
+
'adaptive-chat-trail': AdaptiveChatTrail;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
//# 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;AAqBD,qBAAa,iBAAkB,SAAQ,UAAU;IAsB/C,OAAgB,MAAM,0BA8FpB;IAEF,OAAgB,UAAU;;;;;;;;;;;;;QAKxB;;;0EAGkE;;;;QAElE;;;;;;;WAOG;;;;QAEH;;;;;;WAMG;;;;QAEH;;;;;;;WAOG;;;;MAEH;IAEF,QAAQ,EAAE,YAAY,EAAE,CAAM;IAC9B,YAAY,SAAmB;IAC/B,QAAQ,UAAS;IACjB,aAAa,UAAS;IACtB,QAAQ,UAAS;IACjB,YAAY,SAAM;IAClB,eAAe,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAAa;IAC3E;;;;;OAKG;IACH,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAa;IAQzC,OAAO,CAAC,SAAS,CAMf;IAEF;;;;;OAKG;IACH,OAAO,CAAC,gBAAgB,CAStB;IAEF,OAAO,CAAC,WAAW,CAMjB;IAEF;;;;;;;;OAQG;IACH,OAAO,CAAC,mBAAmB;IAiBlB,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAyBrD,OAAO,CAAC,uBAAuB,CAU7B;IAEF;;;;;;;;;OASG;IACH,OAAO,CAAC,sBAAsB,CAU5B;IAEO,MAAM;CAsXhB;AA+BD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,MAAM,eAAe,GACvB;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,QAAQ,CAAA;CAAE,GAC1D;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,GACrB;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,GACnB;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,QAAQ,CAAA;CAAE,CAAC;AA4iB7D,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,qBAAqB,EAAE,iBAAiB,CAAC;KAC1C;CACF"}
|