@syntrologie/adapt-chatbot 2.8.0-canary.43 → 2.8.0-canary.430
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +80 -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 +415 -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 +230 -0
- package/dist/ChatSession.d.ts.map +1 -0
- package/dist/ChatTransport.d.ts +360 -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/TextAnswerMountable.test.d.ts +2 -0
- package/dist/TextAnswerMountable.test.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-7WSMNAKW.js +3824 -0
- package/dist/chunk-7WSMNAKW.js.map +7 -0
- package/dist/chunk-EWPPVPJ4.js +14 -0
- package/dist/chunk-EWPPVPJ4.js.map +7 -0
- package/dist/chunk-GP4OSTZT.js +641 -0
- package/dist/chunk-GP4OSTZT.js.map +7 -0
- package/dist/chunk-HELUC5JI.js +8971 -0
- package/dist/chunk-HELUC5JI.js.map +7 -0
- package/dist/chunk-HVGQJZMP.js +1520 -0
- package/dist/chunk-HVGQJZMP.js.map +7 -0
- package/dist/chunk-KPWW7N27.js +235 -0
- package/dist/chunk-KPWW7N27.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__/lifecycle.test.d.ts +2 -0
- package/dist/observer/__tests__/lifecycle.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 +63 -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 +2232 -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,360 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ChatTransport — singleton transport adapter that bridges chatSession
|
|
3
|
+
* (the view-side state holder) to the real backend chat pipeline
|
|
4
|
+
* (AG-UI SSE at `/api/adaptive/stream`).
|
|
5
|
+
*
|
|
6
|
+
* This is the unification of two formerly separate paths:
|
|
7
|
+
* - `ChatAssistantLit` (old) owns the transport plumbing —
|
|
8
|
+
* AgUiTransport, Cloudflare Turnstile, headers, A2UI passthrough,
|
|
9
|
+
* telemetry, fallback card.
|
|
10
|
+
* - `AdaptiveChatBar` + `chatSession` (new) owns the canvas-lid UX —
|
|
11
|
+
* glassmorphism bar, bubble-up trail, per-page persistence.
|
|
12
|
+
*
|
|
13
|
+
* This module ports every transport-side concern from ChatAssistantLit
|
|
14
|
+
* into a session-shaped adapter so the new bar gets full backend
|
|
15
|
+
* parity. The bar stays a pure view; the transport stays a pure pipe.
|
|
16
|
+
*
|
|
17
|
+
* Lifecycle:
|
|
18
|
+
* - `configure({ backendUrl, runtime, ... })` — called once by the
|
|
19
|
+
* SDK runtime at bootstrap from chat config. Idempotent; second
|
|
20
|
+
* call with the same backendUrl is a no-op.
|
|
21
|
+
* - Connection is LAZY. The transport doesn't acquire Turnstile or
|
|
22
|
+
* open the SSE until the first chatSession.send() — saves cost
|
|
23
|
+
* on pages where the user never opens chat.
|
|
24
|
+
* - On chatSession.send → transport ensures connected (acquires
|
|
25
|
+
* Turnstile token, builds AgUiTransport) then forwards
|
|
26
|
+
* `{type:'user-message', text}` to the agent.
|
|
27
|
+
* - On chatSession.onInterrupt → transport sends stop-generation.
|
|
28
|
+
* - AgUi events stream into chatSession via receiveStart / Delta /
|
|
29
|
+
* End / error.
|
|
30
|
+
* - A2UI custom events forward to runtime.actions.applyBatch so the
|
|
31
|
+
* agent can drive canvas updates.
|
|
32
|
+
*
|
|
33
|
+
* Telemetry parity with ChatAssistantLit:
|
|
34
|
+
* - chatbot.transport_error (every error, with status/body/name)
|
|
35
|
+
* - chatbot.a2ui_applied
|
|
36
|
+
* - chatbot.fallback_rendered — emitted when the transport gives up
|
|
37
|
+
* (Turnstile failed AND backend rejected) so existing PostHog
|
|
38
|
+
* queries keep working.
|
|
39
|
+
*
|
|
40
|
+
* Threading model: single-flight per page. Multiple concurrent sends
|
|
41
|
+
* are queued by AgUiTransport itself. Multiple bar mounts share this
|
|
42
|
+
* one transport via chatSession.
|
|
43
|
+
*/
|
|
44
|
+
import type { ElementMutation } from './elements';
|
|
45
|
+
import type { ChatbotWidgetRuntime } from './types';
|
|
46
|
+
/**
|
|
47
|
+
* Per-customer "chat unavailable" card config. Surfaced via onFallback
|
|
48
|
+
* when the transport gives up after repeated failures. Mirrors
|
|
49
|
+
* ChatbotFallback in types.ts so consumers can pass the same config.
|
|
50
|
+
*/
|
|
51
|
+
export interface ChatbotFallbackConfig {
|
|
52
|
+
title?: string;
|
|
53
|
+
message?: string;
|
|
54
|
+
ctaLabel?: string;
|
|
55
|
+
ctaHref?: string;
|
|
56
|
+
}
|
|
57
|
+
export interface ChatTransportConfig {
|
|
58
|
+
/** Backend host, e.g. "https://demo-api.syntrologie.com" or "" for same-origin. */
|
|
59
|
+
backendUrl: string;
|
|
60
|
+
/** Runtime hooks for A2UI apply + telemetry. */
|
|
61
|
+
runtime: ChatbotWidgetRuntime;
|
|
62
|
+
/** Optional thread id for conversation continuity across reloads. */
|
|
63
|
+
threadId?: string;
|
|
64
|
+
/**
|
|
65
|
+
* Optional set of client-tool names the transport should treat as
|
|
66
|
+
* "needs user approval" (surfaced via chatSession.toolCalls instead
|
|
67
|
+
* of auto-executed server-side). Empty by default — all tool calls
|
|
68
|
+
* are server-driven and the transport just emits the "tool call
|
|
69
|
+
* happened" event.
|
|
70
|
+
*/
|
|
71
|
+
clientTools?: Set<string>;
|
|
72
|
+
/**
|
|
73
|
+
* Per-customer "chat unavailable" card. Rendered by the host
|
|
74
|
+
* (typically AdaptiveChatBarMountable) after repeated connect
|
|
75
|
+
* failures wipe the chat surface — exactly the same UX
|
|
76
|
+
* ChatAssistantLit's fallback path provides.
|
|
77
|
+
*/
|
|
78
|
+
fallback?: ChatbotFallbackConfig;
|
|
79
|
+
/**
|
|
80
|
+
* Arbitrary JSON object attached to every AG-UI request as
|
|
81
|
+
* `forwardedProps`. Used by the adaptive chat surface to ship the
|
|
82
|
+
* LLM-authored UI element config (`uiTemplates`, `elementsEnabled`)
|
|
83
|
+
* per request — the backend reads these to enable the
|
|
84
|
+
* `mount_element` / `patch_element` / `unmount_element` tools.
|
|
85
|
+
* Callable form is re-evaluated on every turn so a config edit can
|
|
86
|
+
* land mid-conversation.
|
|
87
|
+
*/
|
|
88
|
+
forwardedProps?: Record<string, unknown> | (() => Record<string, unknown> | undefined);
|
|
89
|
+
/**
|
|
90
|
+
* Optional callback for `syntro.element.mutation` AG-UI custom events.
|
|
91
|
+
* The transport decodes the envelope on receipt; if it matches the
|
|
92
|
+
* element-mutation schema, mutations are routed here instead of the
|
|
93
|
+
* generic `runtime.actions.applyBatch` legacy path. Consumers are
|
|
94
|
+
* expected to forward to `ElementInstanceStore.apply(mutations)` —
|
|
95
|
+
* we don't take a store reference directly so the transport stays
|
|
96
|
+
* agnostic of which surface owns the store (the chat-bar widget
|
|
97
|
+
* may own one; ChatAssistantLit owns its own; both share this
|
|
98
|
+
* singleton transport).
|
|
99
|
+
*
|
|
100
|
+
* When unset, element-mutation envelopes fall back to applyBatch,
|
|
101
|
+
* matching legacy behaviour (which would no-op since applyBatch
|
|
102
|
+
* doesn't know about MutationEnvelope).
|
|
103
|
+
*/
|
|
104
|
+
onElementMutation?: (mutations: ElementMutation[]) => void;
|
|
105
|
+
/**
|
|
106
|
+
* Slot the chat-bar widget is mounted into (e.g. ``"drawer"``,
|
|
107
|
+
* ``"adaptive-chat"``). Forwarded as ``X-Active-Lid-Slot`` on every
|
|
108
|
+
* ``/api/adaptive/stream`` request so the backend can route mounts to
|
|
109
|
+
* the canvas next to whichever lid the visitor sent from. Optional —
|
|
110
|
+
* omitting it falls back to the template's static ``default_slot``
|
|
111
|
+
* server-side, which is the pre-change behaviour.
|
|
112
|
+
*/
|
|
113
|
+
activeLidSlot?: string;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Debounce window for connect errors. Single transient errors
|
|
117
|
+
* (cold-start 502, brief CORS preflight failure) should NOT swap the
|
|
118
|
+
* chat to the fallback card; only sustained failure should. Matches
|
|
119
|
+
* ChatAssistantLit's ERROR_DEBOUNCE_MS.
|
|
120
|
+
*/
|
|
121
|
+
export declare const FALLBACK_DEBOUNCE_MS = 1500;
|
|
122
|
+
export interface FallbackPayload {
|
|
123
|
+
reason: 'connect_failed' | 'connect_timeout';
|
|
124
|
+
fallback: ChatbotFallbackConfig;
|
|
125
|
+
transportId: string;
|
|
126
|
+
transportAgeMs: number;
|
|
127
|
+
messagesSucceeded: number;
|
|
128
|
+
hadTurnstileToken: boolean | null;
|
|
129
|
+
errorStatus: number | null;
|
|
130
|
+
errorBody: string | null;
|
|
131
|
+
errorMessage: string | null;
|
|
132
|
+
errorName: string | null;
|
|
133
|
+
}
|
|
134
|
+
export type FallbackListener = (payload: FallbackPayload) => void;
|
|
135
|
+
/**
|
|
136
|
+
* Visitor-facing progress copy for a tool call, shown in the thinking chip.
|
|
137
|
+
* Returns an ORDERED set of phrasings for the tool's category: the first shows
|
|
138
|
+
* immediately, and `ChatTransport` rotates through the rest every few seconds
|
|
139
|
+
* while the same phase runs (see `_startThinkingCycle`) so a long — or looping
|
|
140
|
+
* — tool phase reads as live progress instead of one frozen string. Keyed on
|
|
141
|
+
* substrings of the (technical) tool name so it survives renames; never shows
|
|
142
|
+
* the raw name.
|
|
143
|
+
*
|
|
144
|
+
* Distinct buckets matter: `retrieve_wiki` (search), `get_wiki_route`
|
|
145
|
+
* (navigate) and `read_section` (read) all used to collapse to one identical
|
|
146
|
+
* "Finding the right page…", which made a multi-call research loop look like a
|
|
147
|
+
* single calm step. Check search/retrieve BEFORE the generic `wiki` fallback so
|
|
148
|
+
* `retrieve_wiki` lands on "Searching…", not "Looking that up…".
|
|
149
|
+
*/
|
|
150
|
+
export declare function toolNarrationVariants(name: string): string[];
|
|
151
|
+
export declare class ChatTransport {
|
|
152
|
+
private _config;
|
|
153
|
+
private _status;
|
|
154
|
+
private _agui;
|
|
155
|
+
private _transportUnsub;
|
|
156
|
+
private _sessionUnsubSend;
|
|
157
|
+
private _sessionUnsubInterrupt;
|
|
158
|
+
private _sessionUnsubToolResult;
|
|
159
|
+
private _connectInFlight;
|
|
160
|
+
/** Bounded streaming-message id for the currently-being-typed assistant turn. */
|
|
161
|
+
private _currentAssistantMessageId;
|
|
162
|
+
/** Outcome bookkeeping for telemetry. */
|
|
163
|
+
private _hadTurnstileToken;
|
|
164
|
+
/** Count of successful round-trips for telemetry payloads. */
|
|
165
|
+
private _messagesSucceeded;
|
|
166
|
+
/** True once a successful assistant message has landed — gates fallback. */
|
|
167
|
+
private _hasSucceeded;
|
|
168
|
+
/** True once fallback has fired (one-shot). */
|
|
169
|
+
private _fallbackRendered;
|
|
170
|
+
/**
|
|
171
|
+
* Per-send override for ``X-Active-Lid-Slot``. Set in the
|
|
172
|
+
* ``chatSession.onSend`` listener immediately before each
|
|
173
|
+
* ``_forwardUserMessage`` and consumed by ``buildHeaders`` on the
|
|
174
|
+
* outbound request. The singleton transport is shared by every
|
|
175
|
+
* mounted chat-bar (drawer + inline) so cached ``_config.activeLidSlot``
|
|
176
|
+
* follows whichever bar last reconfigured — using that for routing
|
|
177
|
+
* silently misroutes tiles when both bars coexist. Per-send threading
|
|
178
|
+
* pins the header to the bar that actually sent the message.
|
|
179
|
+
*/
|
|
180
|
+
private _pendingLidSlot;
|
|
181
|
+
/** Active debounce timer; null when no debounce pending. */
|
|
182
|
+
private _errorDebounceTimer;
|
|
183
|
+
/** Rotates thinking-chip phrasings during a long/looping tool phase (C9). */
|
|
184
|
+
private _thinkingCycleTimer;
|
|
185
|
+
/**
|
|
186
|
+
* Per-class rotation counter, keyed by the narration set's first variant.
|
|
187
|
+
* A NEW tool class shows its primary (variant A) so it's recognizable; a
|
|
188
|
+
* REPEATED same-class call advances to the next variant, so a research loop
|
|
189
|
+
* of (e.g.) several searches reads as different thinking, not one repeated
|
|
190
|
+
* label. Bounded to ~6 keys (one per tool class).
|
|
191
|
+
*/
|
|
192
|
+
private _thinkingClassSeq;
|
|
193
|
+
/** Most recent error payload, captured so debounced fallback can attach it. */
|
|
194
|
+
private _lastErrorPayload;
|
|
195
|
+
private _fallbackListeners;
|
|
196
|
+
/**
|
|
197
|
+
* Per-configure-cycle id for correlating telemetry events from a
|
|
198
|
+
* single transport lifetime. Mirrors ChatAssistantLit's mountId
|
|
199
|
+
* but scoped to configure cycles since the transport is a
|
|
200
|
+
* singleton across mounts.
|
|
201
|
+
*/
|
|
202
|
+
private _transportId;
|
|
203
|
+
private _configuredAt;
|
|
204
|
+
/**
|
|
205
|
+
* Configure the transport. Idempotent — calling again with the same
|
|
206
|
+
* backendUrl is a no-op; calling with a different backendUrl tears
|
|
207
|
+
* the connection down and re-arms.
|
|
208
|
+
*/
|
|
209
|
+
configure(config: ChatTransportConfig): void;
|
|
210
|
+
/** ms since the most recent configure() call. 0 before any configure. */
|
|
211
|
+
private _ageMs;
|
|
212
|
+
/** True when configure() has been called and we're ready to lazy-connect on send. */
|
|
213
|
+
get isConfigured(): boolean;
|
|
214
|
+
/** True when AgUiTransport is up. */
|
|
215
|
+
get isConnected(): boolean;
|
|
216
|
+
/**
|
|
217
|
+
* Subscribe to fallback events — fires once per configure cycle
|
|
218
|
+
* when the transport gives up after sustained failure. Hosts
|
|
219
|
+
* (typically AdaptiveChatBarMountable) use this to swap the chat
|
|
220
|
+
* bar for a static "contact support" card.
|
|
221
|
+
*/
|
|
222
|
+
onFallback(listener: FallbackListener): () => void;
|
|
223
|
+
/**
|
|
224
|
+
* Test seam — drive a synthetic error event through the transport's
|
|
225
|
+
* error handling without standing up a real AgUi transport. Production
|
|
226
|
+
* code path uses _onTransportEvent. Exported as a public method to
|
|
227
|
+
* keep the test isolation simple; not part of the documented API.
|
|
228
|
+
*/
|
|
229
|
+
simulateError(payload: {
|
|
230
|
+
message?: string;
|
|
231
|
+
status?: number | null;
|
|
232
|
+
body?: string | null;
|
|
233
|
+
errorName?: string | null;
|
|
234
|
+
}): void;
|
|
235
|
+
/**
|
|
236
|
+
* Test seam — drive the FULL server-error path (fallback kernel + the
|
|
237
|
+
* visitor-facing chip), exactly what the `case 'error'` transport-event
|
|
238
|
+
* branch does. `midAnswer` simulates an assistant message having been
|
|
239
|
+
* mid-stream when the connection died.
|
|
240
|
+
*/
|
|
241
|
+
simulateServerError(payload: {
|
|
242
|
+
message?: string;
|
|
243
|
+
status?: number | null;
|
|
244
|
+
body?: string | null;
|
|
245
|
+
errorName?: string | null;
|
|
246
|
+
midAnswer?: boolean;
|
|
247
|
+
}): void;
|
|
248
|
+
/**
|
|
249
|
+
* Test seam — register a synthetic successful message-complete so
|
|
250
|
+
* the hasSucceeded gate flips without a real AgUi round-trip.
|
|
251
|
+
*/
|
|
252
|
+
simulateSuccessfulMessage(): void;
|
|
253
|
+
/**
|
|
254
|
+
* Test seam — return the lid slot that the next outbound request
|
|
255
|
+
* WOULD tag ``X-Active-Lid-Slot`` with, given current state. Mirrors
|
|
256
|
+
* the exact resolution buildHeaders uses (per-send slot wins over
|
|
257
|
+
* cached config). Not part of the documented API.
|
|
258
|
+
*/
|
|
259
|
+
getActiveLidSlotForTest(): string | null;
|
|
260
|
+
/**
|
|
261
|
+
* Tear connection-level state down. Used internally by configure()
|
|
262
|
+
* to swap backends; preserves host-registered fallback listeners
|
|
263
|
+
* because the host UI handler (e.g. AdaptiveChatBarMountable's
|
|
264
|
+
* "swap to fallback card" callback) is configuration-independent.
|
|
265
|
+
*/
|
|
266
|
+
private _disconnect;
|
|
267
|
+
/**
|
|
268
|
+
* Tear everything down — connection state PLUS host listeners.
|
|
269
|
+
* Use this in test teardown or when fully shutting the transport
|
|
270
|
+
* (page unload, integration test reset). The mountable calls
|
|
271
|
+
* _disconnect indirectly via reconfigure.
|
|
272
|
+
*/
|
|
273
|
+
reset(): void;
|
|
274
|
+
/** AbortController for the live /session SSE reader; null = not running. */
|
|
275
|
+
private _sessionStreamAbort;
|
|
276
|
+
/** Capped reconnect backoff for the session stream. */
|
|
277
|
+
private _sessionStreamBackoffMs;
|
|
278
|
+
/**
|
|
279
|
+
* Open the persistent `/api/adaptive/session` SSE and feed its frames
|
|
280
|
+
* through the SAME `_onTransportEvent` switch the AG-UI path uses
|
|
281
|
+
* (FEAT-1783640628 — proactive nudges).
|
|
282
|
+
*
|
|
283
|
+
* The AG-UI cutover left this endpoint with no client consumer, so
|
|
284
|
+
* server-INITIATED events had nowhere to land. A fetch-based reader —
|
|
285
|
+
* unlike EventSource — can send the SDK token, and the visitor ids that
|
|
286
|
+
* write the server's nudge identity bridge. Idempotent; reconnects with
|
|
287
|
+
* capped backoff; `reset()`/`stopSessionStream()` tears it down.
|
|
288
|
+
*/
|
|
289
|
+
startSessionStream(): Promise<void>;
|
|
290
|
+
stopSessionStream(): void;
|
|
291
|
+
private _clearDebounceTimer;
|
|
292
|
+
/**
|
|
293
|
+
* Show a per-call rotating variant in the thinking chip immediately (so
|
|
294
|
+
* consecutive tool calls differ), then rotate through the remaining phrasings
|
|
295
|
+
* every 4s while the same tool phase runs (C9). A
|
|
296
|
+
* single tool call can sit for tens of seconds (the model reasoning about the
|
|
297
|
+
* next step, or a slow retrieval); a static chip reads as frozen and hides a
|
|
298
|
+
* loop. Cycling makes a long/looping phase read as live progress. Restarting
|
|
299
|
+
* (a new tool), any output (message/thinking), or teardown clears the cycle.
|
|
300
|
+
*/
|
|
301
|
+
private _startThinkingCycle;
|
|
302
|
+
private _stopThinkingCycle;
|
|
303
|
+
/**
|
|
304
|
+
* Shared error-handling kernel — called by the AG-UI subscriber and
|
|
305
|
+
* by the simulateError test seam. Publishes transport_error
|
|
306
|
+
* telemetry, captures lastErrorPayload, and starts the debounce
|
|
307
|
+
* timer that will fire fallback if no successful message arrives
|
|
308
|
+
* before it expires. Gated by hasSucceeded (post-success errors
|
|
309
|
+
* never fallback) and _fallbackRendered (one-shot).
|
|
310
|
+
*/
|
|
311
|
+
private _handleErrorEvent;
|
|
312
|
+
/**
|
|
313
|
+
* Fire the fallback. One-shot per configure cycle. Notifies all
|
|
314
|
+
* fallback listeners with the per-customer card config and the
|
|
315
|
+
* diagnostic snapshot for telemetry/debug.
|
|
316
|
+
*/
|
|
317
|
+
private _renderFallback;
|
|
318
|
+
private _wireSession;
|
|
319
|
+
private _forwardUserMessage;
|
|
320
|
+
/**
|
|
321
|
+
* Ensure AgUiTransport is up. Idempotent — multiple concurrent calls
|
|
322
|
+
* dedupe to a single Turnstile acquisition + transport setup.
|
|
323
|
+
* Returns true on success, false on terminal failure.
|
|
324
|
+
*/
|
|
325
|
+
private _ensureConnected;
|
|
326
|
+
/**
|
|
327
|
+
* Acquire a Turnstile token via the managed-challenge flow.
|
|
328
|
+
* Delegates to the shared Turnstile helper that owns the verify
|
|
329
|
+
* panel lifecycle. Returns null when Turnstile is disabled at
|
|
330
|
+
* build time or acquisition fails.
|
|
331
|
+
*/
|
|
332
|
+
private _acquireTurnstileWithChallenge;
|
|
333
|
+
/**
|
|
334
|
+
* Look up a tool call's current chatSession-side status by id.
|
|
335
|
+
* Used to decide between addToolCall (first sighting) and
|
|
336
|
+
* updateToolCall (subsequent updates) when AG-UI re-emits
|
|
337
|
+
* `tool-call` events for client tools transitioning to 'pending'.
|
|
338
|
+
*/
|
|
339
|
+
private _findToolCallStatus;
|
|
340
|
+
/**
|
|
341
|
+
* Convert one server-transcript message (the session store shape:
|
|
342
|
+
* ``{id, role, content, timestamp, status, toolCalls?}`` with toolCalls
|
|
343
|
+
* in AG-UI wire shape) into a TrailMessage. Returns null for entries the
|
|
344
|
+
* trail can't render (missing id, system/tool roles, empty content with
|
|
345
|
+
* no tool receipts) — the transcript may legitimately contain them.
|
|
346
|
+
*/
|
|
347
|
+
private _snapshotToTrailMessage;
|
|
348
|
+
/** AG-UI wire-shape toolCalls → settled TrailToolCall receipts. */
|
|
349
|
+
private _snapshotToolCalls;
|
|
350
|
+
/** Map AG-UI ToolCallStatus to TrailToolCall status. */
|
|
351
|
+
private _mapToolCallStatus;
|
|
352
|
+
private _onTransportEvent;
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* The module-level singleton. Imported by both the SDK runtime
|
|
356
|
+
* bootstrap (to call configure) and any code that needs to read
|
|
357
|
+
* transport state. Mirrors the chatSession singleton shape.
|
|
358
|
+
*/
|
|
359
|
+
export declare const chatTransport: ChatTransport;
|
|
360
|
+
//# sourceMappingURL=ChatTransport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+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;;;;;;;OAUG;IACG,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC;IAgIzC,iBAAiB,IAAI,IAAI;IAMzB,OAAO,CAAC,mBAAmB;IAO3B;;;;;;;;OAQG;IACH,OAAO,CAAC,mBAAmB;IAwB3B,OAAO,CAAC,kBAAkB;IAO1B;;;;;;;OAOG;IACH,OAAO,CAAC,iBAAiB;IA0CzB;;;;OAIG;IACH,OAAO,CAAC,eAAe;IA4BvB,OAAO,CAAC,YAAY;YAkBN,mBAAmB;IA6BjC;;;;OAIG;YACW,gBAAgB;IA6I9B;;;;;OAKG;YACW,8BAA8B;IAS5C;;;;;OAKG;IACH,OAAO,CAAC,mBAAmB;IAS3B;;;;;;OAMG;IACH,OAAO,CAAC,uBAAuB;IAe/B,mEAAmE;IACnE,OAAO,CAAC,kBAAkB;IAwB1B,wDAAwD;IACxD,OAAO,CAAC,kBAAkB;IAiB1B,OAAO,CAAC,iBAAiB;CAuN1B;AAED;;;;GAIG;AACH,eAAO,MAAM,aAAa,eAAsB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InlineRegistryWidgetMount.test.d.ts","sourceRoot":"","sources":["../src/InlineRegistryWidgetMount.test.ts"],"names":[],"mappings":"AAiCA,OAAO,mBAAmB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InlineWidgetLiveMount.test.d.ts","sourceRoot":"","sources":["../src/InlineWidgetLiveMount.test.ts"],"names":[],"mappings":"AAmCA,OAAO,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NavLinkMountable — `MountableWidget` used as the payload of an
|
|
3
|
+
* LLM-authored navigation chip.
|
|
4
|
+
*
|
|
5
|
+
* Flow:
|
|
6
|
+
* LLM mounts `suggest-navigation` ItemTemplate with `{title, url}`
|
|
7
|
+
* → backend builds chip with payload `{widget: 'adaptive-chatbot:nav-link', props: {url}}`
|
|
8
|
+
* → user clicks the chip → chips-strip mounts THIS widget into the
|
|
9
|
+
* chip's drawer
|
|
10
|
+
* → user clicks the "Go to <url>" button this widget renders
|
|
11
|
+
* → same-origin SPA navigation via pushState + popstate (matches
|
|
12
|
+
* `adaptive-nav`'s `executeNavigate` path for SPA-router compatibility)
|
|
13
|
+
*
|
|
14
|
+
* Registered as widget id `adaptive-chatbot:nav-link`.
|
|
15
|
+
*
|
|
16
|
+
* Security note: only http(s), same-origin destinations are honored.
|
|
17
|
+
* `javascript:`, `data:`, and cross-origin URLs are silently dropped at
|
|
18
|
+
* URL construction. The ItemTemplate's EnumField allowlist is the
|
|
19
|
+
* primary constraint; this is defense-in-depth.
|
|
20
|
+
*/
|
|
21
|
+
export declare const NavLinkMountable: {
|
|
22
|
+
mount(container: HTMLElement, mountConfig?: Record<string, unknown>): () => void;
|
|
23
|
+
update(container: HTMLElement, mountConfig?: Record<string, unknown>): void;
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=NavLinkMountable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NavLinkMountable.d.ts","sourceRoot":"","sources":["../src/NavLinkMountable.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAoEH,eAAO,MAAM,gBAAgB;qBACV,WAAW,gBAAgB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,IAAI;sBAkB9D,WAAW,gBAAgB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;CAO5E,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NavLinkMountable.test.d.ts","sourceRoot":"","sources":["../src/NavLinkMountable.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TextAnswerMountable — `MountableWidget` for the simplest chip payload
|
|
3
|
+
* kind: a single paragraph of body text.
|
|
4
|
+
*
|
|
5
|
+
* Registered as widget id `adaptive-chatbot:text-answer`. Used by
|
|
6
|
+
* `AdaptiveChipsStrip` when a chip's payload references it.
|
|
7
|
+
*
|
|
8
|
+
* Replaces the old hand-rolled resolver path. Customers wanting richer
|
|
9
|
+
* payloads (markdown, mini-product cards, embedded charts, etc.) ship
|
|
10
|
+
* their own mountable through the same registry — no special
|
|
11
|
+
* resolver-map seam.
|
|
12
|
+
*/
|
|
13
|
+
export declare const TextAnswerMountable: {
|
|
14
|
+
mount(container: HTMLElement, mountConfig?: Record<string, unknown>): () => void;
|
|
15
|
+
update(container: HTMLElement, mountConfig?: Record<string, unknown>): void;
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=TextAnswerMountable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextAnswerMountable.d.ts","sourceRoot":"","sources":["../src/TextAnswerMountable.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAwBH,eAAO,MAAM,mBAAmB;qBACb,WAAW,gBAAgB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,IAAI;sBAqB9D,WAAW,gBAAgB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;CAO5E,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextAnswerMountable.test.d.ts","sourceRoot":"","sources":["../src/TextAnswerMountable.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turnstile — shared Cloudflare bot-check helpers.
|
|
3
|
+
*
|
|
4
|
+
* Originally lived inline in ChatAssistantLit. Extracted so the new
|
|
5
|
+
* ChatTransport adapter can use the same managed-challenge flow
|
|
6
|
+
* without duplicating the panel-portal logic.
|
|
7
|
+
*
|
|
8
|
+
* Verify-panel is mounted to `document.body` (NOT into the calling
|
|
9
|
+
* widget's shadow-rooted container). Cloudflare Turnstile crashes
|
|
10
|
+
* with `Cannot read properties of undefined (reading 'toLowerCase')`
|
|
11
|
+
* when its host element lives inside a shadow root (verified on
|
|
12
|
+
* healthmaxxer 2026-05-22 — chat tile inside `<smart-canvas>`'s open
|
|
13
|
+
* shadow root). So we portal the host out and position it as a fixed
|
|
14
|
+
* overlay at the bottom-center of the viewport.
|
|
15
|
+
*
|
|
16
|
+
* The panel is ALWAYS mounted (CF needs a DOM target in case it
|
|
17
|
+
* decides to challenge) but is off-screen by default. For clean
|
|
18
|
+
* traffic, CF passive-grades silently with
|
|
19
|
+
* `appearance: 'interaction-only'` — nothing is ever visible. For
|
|
20
|
+
* flagged sessions, CF's `before-interactive-callback` fires and the
|
|
21
|
+
* orchestration helper reveals the panel.
|
|
22
|
+
*
|
|
23
|
+
* Copy is intentionally generic — customer end-users see this when CF
|
|
24
|
+
* flags their session, regardless of customer.
|
|
25
|
+
*/
|
|
26
|
+
export declare const TURNSTILE_SITEKEY = "0x4AAAAAADSzPbGWxeguF4YJ";
|
|
27
|
+
export interface AcquireTurnstileOptions {
|
|
28
|
+
/** Widget size. `flexible` (default for managed-mode sitekeys). */
|
|
29
|
+
size?: 'flexible' | 'normal' | 'compact' | 'invisible';
|
|
30
|
+
/** `interaction-only` keeps the widget invisible during passive grading. */
|
|
31
|
+
appearance?: 'always' | 'execute' | 'interaction-only';
|
|
32
|
+
/** Where to mount the widget. Off-screen host created when omitted. */
|
|
33
|
+
host?: HTMLElement;
|
|
34
|
+
/** Fires when CF decides a challenge is needed — surface "verifying" copy. */
|
|
35
|
+
onBeforeInteractive?: () => void;
|
|
36
|
+
/** Cancels an in-flight acquisition. Required for clean unmount-during-challenge. */
|
|
37
|
+
signal?: AbortSignal;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Acquire a Cloudflare Turnstile token. Returns null when:
|
|
41
|
+
* • TURNSTILE_SITEKEY is empty (Turnstile disabled at build time)
|
|
42
|
+
* • the script fails to load (customer CSP blocks Cloudflare, etc.)
|
|
43
|
+
* • the render callback doesn't fire within TURNSTILE_ACQUIRE_TIMEOUT_MS
|
|
44
|
+
* • Cloudflare returns an error-callback (e.g., rate-limited, bad sitekey)
|
|
45
|
+
*
|
|
46
|
+
* Calls `turnstile.remove(widgetId)` on settle so CF's internal widget
|
|
47
|
+
* registry doesn't leak across re-mounts.
|
|
48
|
+
*
|
|
49
|
+
* Exported for tests and for the higher-level acquireTokenWithChallenge
|
|
50
|
+
* helper below.
|
|
51
|
+
*/
|
|
52
|
+
export declare function acquireTurnstileToken(opts?: AcquireTurnstileOptions): Promise<string | null>;
|
|
53
|
+
/**
|
|
54
|
+
* Mount the off-screen verify-panel that hosts the managed Turnstile
|
|
55
|
+
* widget. Returns the panel element; callers MUST call panel.remove()
|
|
56
|
+
* when done (the panel is mounted on document.body and won't be
|
|
57
|
+
* garbage-collected with their widget).
|
|
58
|
+
*/
|
|
59
|
+
export declare function renderVerifyPanel(): HTMLElement;
|
|
60
|
+
/**
|
|
61
|
+
* Move the verify panel on-screen when CF signals via
|
|
62
|
+
* `before-interactive-callback` that the checkbox is about to appear.
|
|
63
|
+
* No-op if the panel was already torn down (race with token resolution).
|
|
64
|
+
*/
|
|
65
|
+
export declare function revealVerifyPanel(panel: HTMLElement | null): void;
|
|
66
|
+
export interface AcquireWithChallengeResult {
|
|
67
|
+
token: string | null;
|
|
68
|
+
outcome: 'disabled' | 'silent_succeeded' | 'interactive_succeeded' | 'acquisition_failed';
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Orchestrated acquire: mount the verify panel, ask CF for a token,
|
|
72
|
+
* reveal the panel if CF decides to challenge interactively, then
|
|
73
|
+
* clean up regardless of outcome.
|
|
74
|
+
*
|
|
75
|
+
* `outcome` is set so callers can distinguish silent-pass from
|
|
76
|
+
* interactive-pass from failure — useful telemetry for "how many
|
|
77
|
+
* sessions actually saw the checkbox?". `disabled` means
|
|
78
|
+
* TURNSTILE_SITEKEY was empty at build time.
|
|
79
|
+
*/
|
|
80
|
+
export declare function acquireTokenWithChallenge(options?: {
|
|
81
|
+
signal?: AbortSignal;
|
|
82
|
+
}): Promise<AcquireWithChallengeResult>;
|
|
83
|
+
//# sourceMappingURL=Turnstile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Turnstile.d.ts","sourceRoot":"","sources":["../src/Turnstile.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAwBH,eAAO,MAAM,iBAAiB,6BAA6B,CAAC;AAmE5D,MAAM,WAAW,uBAAuB;IACtC,mEAAmE;IACnE,IAAI,CAAC,EAAE,UAAU,GAAG,QAAQ,GAAG,SAAS,GAAG,WAAW,CAAC;IACvD,4EAA4E;IAC5E,UAAU,CAAC,EAAE,QAAQ,GAAG,SAAS,GAAG,kBAAkB,CAAC;IACvD,uEAAuE;IACvE,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,8EAA8E;IAC9E,mBAAmB,CAAC,EAAE,MAAM,IAAI,CAAC;IACjC,qFAAqF;IACrF,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,qBAAqB,CACzC,IAAI,GAAE,uBAA4B,GACjC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAyFxB;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,IAAI,WAAW,CAkC/C;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI,GAAG,IAAI,CAMjE;AAED,MAAM,WAAW,0BAA0B;IACzC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,OAAO,EAAE,UAAU,GAAG,kBAAkB,GAAG,uBAAuB,GAAG,oBAAoB,CAAC;CAC3F;AAED;;;;;;;;;GASG;AACH,wBAAsB,yBAAyB,CAC7C,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,WAAW,CAAA;CAAO,GACrC,OAAO,CAAC,0BAA0B,CAAC,CAgDrC"}
|
package/dist/cdn.d.ts
CHANGED
|
@@ -4,11 +4,7 @@
|
|
|
4
4
|
* This module is bundled for CDN delivery and self-registers with the global
|
|
5
5
|
* SynOS app registry when loaded dynamically via the AppLoader.
|
|
6
6
|
*/
|
|
7
|
-
import
|
|
8
|
-
/**
|
|
9
|
-
* App manifest for registry registration.
|
|
10
|
-
* Follows the AppManifest interface expected by AppLoader/AppRegistry.
|
|
11
|
-
*/
|
|
7
|
+
import { ChatbotEditorLit } from './editor-lit';
|
|
12
8
|
export declare const manifest: {
|
|
13
9
|
id: string;
|
|
14
10
|
version: string;
|
|
@@ -29,7 +25,7 @@ export declare const manifest: {
|
|
|
29
25
|
}[];
|
|
30
26
|
};
|
|
31
27
|
editor: {
|
|
32
|
-
component: typeof
|
|
28
|
+
component: typeof ChatbotEditorLit;
|
|
33
29
|
panel: {
|
|
34
30
|
title: string;
|
|
35
31
|
icon: string;
|
package/dist/cdn.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cdn.d.ts","sourceRoot":"","sources":["../src/cdn.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"cdn.d.ts","sourceRoot":"","sources":["../src/cdn.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGhD,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoBpB,CAAC;AAaF,eAAe,QAAQ,CAAC"}
|