@helpai/elements 0.14.1 → 0.15.0
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/README.md +3 -3
- package/configurator.mjs +17 -15
- package/elements-web-component.esm.js +13 -13
- package/elements-web-component.esm.js.map +4 -4
- package/elements.cjs.js +13 -13
- package/elements.cjs.js.map +4 -4
- package/elements.esm.js +13 -13
- package/elements.esm.js.map +4 -4
- package/elements.js +13 -13
- package/elements.js.map +4 -4
- package/index.d.ts +43 -40
- package/index.mjs +439 -402
- package/package.json +1 -1
- package/schema.d.ts +7 -7
- package/schema.json +21 -21
- package/schema.mjs +19 -17
- package/style.css +1 -1
- package/web-component.d.ts +1 -1
- package/web-component.mjs +436 -399
package/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as Asset, B as BlocksConfig, C as ConnectionConfig, a as ConnectionConfigPartial, L as Link, S as ServerConfig, b as SiteConfig, c as
|
|
1
|
+
export { A as Asset, B as BlocksConfig, C as ConnectionConfig, a as ConnectionConfigPartial, L as Link, S as ServerConfig, b as SiteConfig, c as StartConversationResponse, W as WidgetConfig, d as WidgetConfigPartial, e as WidgetSettings, f as WidgetSettingsPartial } from './deployment-P3CoZ-BV.js';
|
|
2
2
|
import 'zod';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -40,7 +40,7 @@ interface ClientStorage {
|
|
|
40
40
|
* populated {@link Strings} map. UI components then read `strings.send` as a
|
|
41
41
|
* normal property access — no per-render lookup, no per-render allocation.
|
|
42
42
|
*/
|
|
43
|
-
type StringKey = "launcherOpen" | "panelTitle" | "composerPlaceholder" | "send" | "stop" | "attach" | "micStart" | "micStop" | "micUnsupported" | "expand" | "collapse" | "fullscreen" | "exitFullscreen" | "resizeHandle" | "scrollToBottom" | "popOut" | "close" | "moreActions" | "soundOn" | "soundOff" | "language" | "theme" | "themeAuto" | "themeLight" | "themeDark" | "history" | "historyTitle" | "historyEmpty" | "historyLoading" | "
|
|
43
|
+
type StringKey = "launcherOpen" | "panelTitle" | "composerPlaceholder" | "send" | "stop" | "attach" | "micStart" | "micStop" | "micUnsupported" | "expand" | "collapse" | "fullscreen" | "exitFullscreen" | "resizeHandle" | "scrollToBottom" | "popOut" | "close" | "moreActions" | "soundOn" | "soundOff" | "language" | "theme" | "themeAuto" | "themeLight" | "themeDark" | "history" | "historyTitle" | "historyEmpty" | "historyLoading" | "historyBack" | "conversationLoading" | "conversationClosed" | "startNewConversation" | "dateToday" | "dateYesterday" | "dateLastWeek" | "dateOlder" | "newConversation" | "dropZone" | "attachmentTooLarge" | "attachmentTooMany" | "attachmentMimeRejected" | "errorRetry" | "errorGeneric" | "errorRateLimited" | "loading" | "thinking" | "thoughts" | "usedTool" | "collapseSidebar" | "expandSidebar" | "formSubmit" | "formSkip" | "formRequired" | "formInvalidEmail" | "formInvalidTel" | "formInvalidUrl" | "formInvalidNumber" | "formTooShort" | "formTooLong" | "formNumberTooSmall" | "formNumberTooLarge" | "formPatternMismatch" | "formChooseAtLeast" | "formChooseAtMost" | "formOther" | "formOtherPlaceholder" | "inputRequired" | "inputSubmit" | "inputSkip" | "inputSubmitted" | "approvalRequired" | "approve" | "reject" | "approved" | "rejected" | "approvalReason" | "stepNoLongerActive" | "tabHome" | "tabConversations" | "tabHelp" | "tabNews" | "modulesEmpty" | "moduleBack" | "contentLoading" | "homeGreeting" | "homeGreetingNamed" | "homeGreetingLead" | "homeSearchPlaceholder" | "homeContentTitle" | "helpTitle" | "helpSearchPlaceholder" | "helpEmpty" | "helpLoading" | "helpSearchEmpty" | "newsTitle" | "newsEmpty" | "newsLoading" | "newsBack" | "newsPublishedAt";
|
|
44
44
|
/** A partial map for one locale — what overrides look like on the wire. */
|
|
45
45
|
type LocaleStrings = Partial<Record<StringKey, string>>;
|
|
46
46
|
/**
|
|
@@ -73,9 +73,9 @@ type StringsOverride = LocaleStrings | Partial<Record<string, LocaleStrings>>;
|
|
|
73
73
|
* 1. **`visitorId`** — anonymous browser-level identifier, minted once per
|
|
74
74
|
* widget instance and reused forever. Sent on every backend request so
|
|
75
75
|
* the server can attach per-visitor settings, history, etc.
|
|
76
|
-
* 2. **`
|
|
76
|
+
* 2. **`conversationId`** — the active conversation thread. The backend is the
|
|
77
77
|
* source of truth for messages; we store only the id and re-fetch on
|
|
78
|
-
* reload via `transport.
|
|
78
|
+
* reload via `transport.loadConversation()`.
|
|
79
79
|
* 3. **`userPrefs`** — user preferences (locale, panel size from drag,
|
|
80
80
|
* sound mute). Cached locally for instant render-before-network, then
|
|
81
81
|
* reconciled with the server's copy on each `connect()`.
|
|
@@ -177,7 +177,7 @@ type WirePart = {
|
|
|
177
177
|
approval?: ToolApproval;
|
|
178
178
|
};
|
|
179
179
|
/** One-shot bot persona shown in the panel header. */
|
|
180
|
-
interface
|
|
180
|
+
interface ConversationAgent {
|
|
181
181
|
name: string;
|
|
182
182
|
/** Image URL or data URI. When omitted, initials render from `name`. */
|
|
183
183
|
avatar?: string;
|
|
@@ -187,7 +187,7 @@ interface SessionAgent {
|
|
|
187
187
|
status?: "online" | "away" | "offline";
|
|
188
188
|
}
|
|
189
189
|
/** A clickable quick-reply chip. */
|
|
190
|
-
interface
|
|
190
|
+
interface ConversationSuggestion {
|
|
191
191
|
id: string;
|
|
192
192
|
/** What the chip displays. */
|
|
193
193
|
label: string;
|
|
@@ -195,36 +195,36 @@ interface SessionSuggestion {
|
|
|
195
195
|
text?: string;
|
|
196
196
|
}
|
|
197
197
|
/** Welcome payload pushed into the message list on first open. */
|
|
198
|
-
interface
|
|
198
|
+
interface ConversationWelcome {
|
|
199
199
|
messages?: Array<{
|
|
200
200
|
id: string;
|
|
201
201
|
role: "assistant" | "system";
|
|
202
202
|
text: string;
|
|
203
203
|
}>;
|
|
204
|
-
suggestions?:
|
|
204
|
+
suggestions?: ConversationSuggestion[];
|
|
205
205
|
}
|
|
206
206
|
/**
|
|
207
|
-
* Response from `POST /ai/agent/start-
|
|
207
|
+
* Response from `POST /ai/agent/start-conversation`. Every field is optional so the
|
|
208
208
|
* backend can opt into surfaces incrementally.
|
|
209
209
|
*
|
|
210
210
|
* The `userPrefs` field (when present) is the server's authoritative
|
|
211
211
|
* copy of per-visitor preferences — the client should adopt it and update
|
|
212
212
|
* its local cache. Lets a user picking French on their phone see the
|
|
213
213
|
* widget in French when they open it on their laptop (assuming the same
|
|
214
|
-
* `visitorId`, e.g. via authenticated
|
|
214
|
+
* `visitorId`, e.g. via authenticated conversation — out of scope for v1).
|
|
215
215
|
*/
|
|
216
|
-
interface
|
|
216
|
+
interface StartConversationResponse {
|
|
217
217
|
/**
|
|
218
|
-
* Public runtime
|
|
218
|
+
* Public runtime conversation id. The widget mints this UUIDv7 and the backend
|
|
219
219
|
* validates that it belongs to the public deployment + visitor.
|
|
220
220
|
*/
|
|
221
|
-
|
|
221
|
+
conversationId: string;
|
|
222
222
|
visitorId?: string;
|
|
223
223
|
canContinue?: boolean;
|
|
224
224
|
/** Bot persona in the panel header (name, avatar, status). */
|
|
225
|
-
agent?:
|
|
225
|
+
agent?: ConversationAgent;
|
|
226
226
|
/** Initial assistant messages + quick-reply chips. */
|
|
227
|
-
welcome?:
|
|
227
|
+
welcome?: ConversationWelcome;
|
|
228
228
|
/**
|
|
229
229
|
* Deployment-wide widget configuration the dashboard admin saved
|
|
230
230
|
* (mode / theme / launcher / actions / composer / features / …).
|
|
@@ -245,9 +245,9 @@ interface StartSessionResponse {
|
|
|
245
245
|
userPrefs?: UserPrefs;
|
|
246
246
|
/**
|
|
247
247
|
* Optional rebind metadata. When the server returns a `visitorId` /
|
|
248
|
-
* `
|
|
248
|
+
* `conversationId` different from what the client sent, this block tells
|
|
249
249
|
* the client WHY — useful for telemetry and the `visitorRebound` /
|
|
250
|
-
* `
|
|
250
|
+
* `conversationRebound` events fired into the host page. Server is free to
|
|
251
251
|
* omit it: the client detects rebinding by comparing request vs
|
|
252
252
|
* response ids regardless.
|
|
253
253
|
*
|
|
@@ -258,7 +258,7 @@ interface StartSessionResponse {
|
|
|
258
258
|
*/
|
|
259
259
|
rebind?: {
|
|
260
260
|
visitorId?: string;
|
|
261
|
-
|
|
261
|
+
conversationId?: string;
|
|
262
262
|
};
|
|
263
263
|
}
|
|
264
264
|
|
|
@@ -288,7 +288,7 @@ type Position = "bottom-right" | "bottom-left" | "top-right" | "top-left";
|
|
|
288
288
|
* `"12px"` horizontal — restore the legacy full-edge
|
|
289
289
|
* slab with `size: { width: "100vw", height: "100vh", inset: "0" }`.
|
|
290
290
|
*
|
|
291
|
-
* Page mode reads `site` and `blocks` from the start-
|
|
291
|
+
* Page mode reads `site` and `blocks` from the start-conversation response.
|
|
292
292
|
*/
|
|
293
293
|
type Mode = "floating" | "inline" | "standalone" | "page" | "modal" | "drawer";
|
|
294
294
|
/** Theme preference. `auto` follows `prefers-color-scheme`. */
|
|
@@ -533,8 +533,11 @@ interface FormCondition {
|
|
|
533
533
|
minMessages?: number;
|
|
534
534
|
maxMessages?: number;
|
|
535
535
|
}
|
|
536
|
-
/**
|
|
537
|
-
|
|
536
|
+
/**
|
|
537
|
+
* How often a form may show: `once` per device (persisted), once per
|
|
538
|
+
* `conversation` (re-eligible when a new conversation starts), or `always`.
|
|
539
|
+
*/
|
|
540
|
+
type FormFrequency = "once" | "conversation" | "always";
|
|
538
541
|
/** One form as authored in config (raw input). */
|
|
539
542
|
interface FormDef {
|
|
540
543
|
/** Stable id — persistence dedupe + `manual` `openForm(id)`. */
|
|
@@ -680,7 +683,7 @@ interface ModuleStatus {
|
|
|
680
683
|
}
|
|
681
684
|
/**
|
|
682
685
|
* `home` layout config — flat feature flags (no block authoring). The Home tab
|
|
683
|
-
* is assembled from these in a fixed order: greeting → search → recent
|
|
686
|
+
* is assembled from these in a fixed order: greeting → search → recent conversation
|
|
684
687
|
* → status → a content list (from the tab's `contentTags`, titled `contentBlockTitle`).
|
|
685
688
|
*/
|
|
686
689
|
interface HomeConfig {
|
|
@@ -689,7 +692,7 @@ interface HomeConfig {
|
|
|
689
692
|
greetingText?: string;
|
|
690
693
|
userAvatars?: ModuleAvatar[];
|
|
691
694
|
showSearchBar?: boolean;
|
|
692
|
-
|
|
695
|
+
showRecentConversations?: boolean;
|
|
693
696
|
status?: ModuleStatus;
|
|
694
697
|
contentBlockTitle?: string;
|
|
695
698
|
}
|
|
@@ -834,7 +837,7 @@ interface BehaviorOptions {
|
|
|
834
837
|
showToolCalls?: boolean;
|
|
835
838
|
/**
|
|
836
839
|
* Override the URL the `popOut` action opens (carries
|
|
837
|
-
* `?
|
|
840
|
+
* `?conversation=<id>&widgetId=<id>`). Falls back to the brand's
|
|
838
841
|
* `BRAND.standaloneUrl` baked at build time. Server-pushable.
|
|
839
842
|
*/
|
|
840
843
|
popOutUrl?: string;
|
|
@@ -953,7 +956,7 @@ interface Endpoints {
|
|
|
953
956
|
* Form submission endpoint. Default: `'/ai/agent/submit-form'`. When any form
|
|
954
957
|
* (a pre-chat lead capture, a CSAT survey, etc.) is completed, the widget POSTs
|
|
955
958
|
* the captured values here (fire-and-forget), keyed by the same `visitorId` +
|
|
956
|
-
* `
|
|
959
|
+
* `conversationId` the conversation uses; the payload carries `formId` + `trigger`
|
|
957
960
|
* so the backend can route. Optional: a backend that doesn't implement it just
|
|
958
961
|
* 404s and the submission is ignored.
|
|
959
962
|
*/
|
|
@@ -963,7 +966,7 @@ interface Endpoints {
|
|
|
963
966
|
/**
|
|
964
967
|
* The three composing roots: raw input ({@link ChatWidgetOptions}),
|
|
965
968
|
* post-normalisation runtime shape ({@link ResolvedOptions}), and the
|
|
966
|
-
* subset the server can push back via `/start-
|
|
969
|
+
* subset the server can push back via `/start-conversation` ({@link
|
|
967
970
|
* ServerConfig}).
|
|
968
971
|
*
|
|
969
972
|
* Internal modules always depend on `ResolvedOptions`. The raw shape
|
|
@@ -992,7 +995,7 @@ interface ChatWidgetOptions {
|
|
|
992
995
|
/**
|
|
993
996
|
* Stable identifier for this widget instance. Use when mounting more
|
|
994
997
|
* than one widget on the same page (different deployments, different
|
|
995
|
-
* targets). Isolates client-storage namespaces (visitorId, active
|
|
998
|
+
* targets). Isolates client-storage namespaces (visitorId, active conversationId,
|
|
996
999
|
* cached userPrefs). Default: `"default"`.
|
|
997
1000
|
*/
|
|
998
1001
|
widgetId?: string;
|
|
@@ -1138,7 +1141,7 @@ interface ResolvedOptions {
|
|
|
1138
1141
|
onError?: ChatWidgetOptions["onError"];
|
|
1139
1142
|
}
|
|
1140
1143
|
/**
|
|
1141
|
-
* Shape of the server-pushed `widget` object in `
|
|
1144
|
+
* Shape of the server-pushed `widget` object in `StartConversationResponse`.
|
|
1142
1145
|
*
|
|
1143
1146
|
* Matches a subset of {@link ChatWidgetOptions} — anything the server can
|
|
1144
1147
|
* reasonably dictate (UI, behaviour, routing). Callbacks (`onMessage` etc.)
|
|
@@ -1245,8 +1248,8 @@ interface EventMap {
|
|
|
1245
1248
|
/** Clear / new-conversation requested. */
|
|
1246
1249
|
clear: void;
|
|
1247
1250
|
/** User picked a chat from the history pane / sidebar. */
|
|
1248
|
-
|
|
1249
|
-
|
|
1251
|
+
selectConversation: {
|
|
1252
|
+
conversationId: string;
|
|
1250
1253
|
};
|
|
1251
1254
|
/** User clicked a suggested-message chip. */
|
|
1252
1255
|
suggestion: {
|
|
@@ -1305,18 +1308,18 @@ interface EventMap {
|
|
|
1305
1308
|
/** An unhandled error occurred somewhere in the transport or UI. */
|
|
1306
1309
|
error: unknown;
|
|
1307
1310
|
/** Connect bootstrap succeeded. Payload is the typed server response. */
|
|
1308
|
-
|
|
1311
|
+
conversationStarted: StartConversationResponse;
|
|
1309
1312
|
/**
|
|
1310
1313
|
* Server rebound the `visitorId` — e.g. the client-minted id
|
|
1311
1314
|
* conflicted with an existing record, was expired, or otherwise
|
|
1312
1315
|
* rejected, and the server returned a fresh one in the
|
|
1313
|
-
* `/start-
|
|
1316
|
+
* `/start-conversation` response. The widget has already adopted the new
|
|
1314
1317
|
* id and persisted it; this event is informational so host pages
|
|
1315
1318
|
* can re-link analytics / external systems that pinned the
|
|
1316
1319
|
* previous value.
|
|
1317
1320
|
*
|
|
1318
1321
|
* `reason` is the server's explanation, when provided
|
|
1319
|
-
* (`rebind.visitorId` in the start-
|
|
1322
|
+
* (`rebind.visitorId` in the start-conversation response). Common values:
|
|
1320
1323
|
* `"conflict"` / `"expired"` / `"invalid"`. May be `undefined` if
|
|
1321
1324
|
* the server didn't include a `rebind` block.
|
|
1322
1325
|
*/
|
|
@@ -1326,12 +1329,12 @@ interface EventMap {
|
|
|
1326
1329
|
reason?: string;
|
|
1327
1330
|
};
|
|
1328
1331
|
/**
|
|
1329
|
-
* Server rebound the `
|
|
1332
|
+
* Server rebound the `conversationId` — same shape and semantics as
|
|
1330
1333
|
* `visitorRebound` but for the conversation-thread id. Fires when
|
|
1331
|
-
* the server's response carries a different `
|
|
1334
|
+
* the server's response carries a different `conversationId` than the
|
|
1332
1335
|
* client sent.
|
|
1333
1336
|
*/
|
|
1334
|
-
|
|
1337
|
+
conversationRebound: {
|
|
1335
1338
|
previous: string;
|
|
1336
1339
|
current: string;
|
|
1337
1340
|
reason?: string;
|
|
@@ -1445,7 +1448,7 @@ interface ChatWidgetInstance {
|
|
|
1445
1448
|
expand: () => void;
|
|
1446
1449
|
/**
|
|
1447
1450
|
* Open the widget in a new browser tab at `behavior.popOutUrl`
|
|
1448
|
-
* (mount option / start-
|
|
1451
|
+
* (mount option / start-conversation-pushable), or the brand's
|
|
1449
1452
|
* `BRAND.standaloneUrl` build-time default. Carries the active
|
|
1450
1453
|
* `chat` + `widgetId` as query params. No-ops when the resolved
|
|
1451
1454
|
* URL is empty.
|
|
@@ -1461,7 +1464,7 @@ interface ChatWidgetInstance {
|
|
|
1461
1464
|
* Subscribe to a lifecycle event. Returns an `off` function. See
|
|
1462
1465
|
* {@link EventMap} for the full set + payload shapes — currently
|
|
1463
1466
|
* `open | close | message | error | expand | fullscreen | popOut |
|
|
1464
|
-
*
|
|
1467
|
+
* conversationStarted | localeChange`.
|
|
1465
1468
|
*/
|
|
1466
1469
|
on: <E extends EventName>(name: E, fn: (payload: EventMap[E]) => void) => () => void;
|
|
1467
1470
|
/**
|
|
@@ -1482,7 +1485,7 @@ interface ChatWidgetInstance {
|
|
|
1482
1485
|
* ```
|
|
1483
1486
|
*/
|
|
1484
1487
|
setUserContext: (userContext: UserContext) => void;
|
|
1485
|
-
/** Clear the end-user context (e.g. on logout) and re-start-
|
|
1488
|
+
/** Clear the end-user context (e.g. on logout) and re-start-conversation anonymously. */
|
|
1486
1489
|
clearUserContext: () => void;
|
|
1487
1490
|
/**
|
|
1488
1491
|
* Set / merge the host-asserted page/visit context (`area`, `url`, `path`,
|
|
@@ -1496,7 +1499,7 @@ interface ChatWidgetInstance {
|
|
|
1496
1499
|
* ```
|
|
1497
1500
|
*/
|
|
1498
1501
|
setPageContext: (pageContext: PageContext) => void;
|
|
1499
|
-
/** Clear the page/visit context and re-start-
|
|
1502
|
+
/** Clear the page/visit context and re-start-conversation. */
|
|
1500
1503
|
clearPageContext: () => void;
|
|
1501
1504
|
/**
|
|
1502
1505
|
* Set the runtime log level. Accepts `"off"` / `"error"` / `"warn"` /
|