@helpai/elements 0.14.0 → 0.14.2
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 +16 -16
- package/elements-web-component.esm.js +25 -25
- package/elements-web-component.esm.js.map +4 -4
- package/elements.cjs.js +27 -27
- package/elements.cjs.js.map +4 -4
- package/elements.esm.js +27 -27
- package/elements.esm.js.map +4 -4
- package/elements.js +25 -25
- package/elements.js.map +4 -4
- package/index.d.ts +46 -45
- package/index.mjs +663 -688
- package/package.json +1 -1
- package/schema.d.ts +55 -57
- package/schema.json +17 -33
- package/schema.mjs +18 -18
- package/style.css +1 -1
- package/web-component.d.ts +1 -1
- package/web-component.mjs +661 -686
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-CWyouRob.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" | "historyNewChat" | "historyBack" | "messagesLoading" | "chatClosed" | "startNewConversation" | "dateToday" | "dateYesterday" | "dateLastWeek" | "dateOlder" | "newConversation" | "dropZone" | "attachmentTooLarge" | "attachmentTooMany" | "attachmentMimeRejected" | "errorRetry" | "errorGeneric" | "errorRateLimited" | "loading" | "thinking" | "thoughts" | "usedTool" | "collapseSidebar" | "expandSidebar" | "formSubmit" | "formSkip" | "
|
|
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" | "historyNewChat" | "historyBack" | "messagesLoading" | "chatClosed" | "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" | "tabMessages" | "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`. */
|
|
@@ -459,10 +459,11 @@ interface FeedbackOptions {
|
|
|
459
459
|
* interfaces are what the resolver, controller, and form UI consume.
|
|
460
460
|
*
|
|
461
461
|
* A deployment declares an array of {@link FormDef}s; each is bound to trigger
|
|
462
|
-
* event(s)
|
|
463
|
-
*
|
|
464
|
-
* verticals — there is NO industry logic; a clinic intake, an
|
|
465
|
-
* form, a CSAT survey, and a sales lead capture are all just
|
|
462
|
+
* event(s) and shown as a gate that replaces the composer (locking the chat
|
|
463
|
+
* until submit/skip). Its answers are recorded via one shared submit endpoint.
|
|
464
|
+
* Generic across verticals — there is NO industry logic; a clinic intake, an
|
|
465
|
+
* insurance claim form, a CSAT survey, and a sales lead capture are all just
|
|
466
|
+
* different config.
|
|
466
467
|
*
|
|
467
468
|
* The same {@link FormField} shape powers the AI-driven ask-input tool.
|
|
468
469
|
*/
|
|
@@ -532,8 +533,11 @@ interface FormCondition {
|
|
|
532
533
|
minMessages?: number;
|
|
533
534
|
maxMessages?: number;
|
|
534
535
|
}
|
|
535
|
-
/**
|
|
536
|
-
|
|
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";
|
|
537
541
|
/** One form as authored in config (raw input). */
|
|
538
542
|
interface FormDef {
|
|
539
543
|
/** Stable id — persistence dedupe + `manual` `openForm(id)`. */
|
|
@@ -545,8 +549,6 @@ interface FormDef {
|
|
|
545
549
|
description?: string;
|
|
546
550
|
submitLabel?: string;
|
|
547
551
|
skippable?: boolean;
|
|
548
|
-
/** Gate the composer. Honored only for `pre-chat` / `after-messages`. */
|
|
549
|
-
blocking?: boolean;
|
|
550
552
|
/** Default `once`. */
|
|
551
553
|
frequency?: FormFrequency;
|
|
552
554
|
/**
|
|
@@ -569,7 +571,6 @@ interface ResolvedForm {
|
|
|
569
571
|
description?: string;
|
|
570
572
|
submitLabel?: string;
|
|
571
573
|
skippable: boolean;
|
|
572
|
-
blocking: boolean;
|
|
573
574
|
frequency: FormFrequency;
|
|
574
575
|
/** Mirror answers into `userContext` (false → PII, endpoint only). */
|
|
575
576
|
mirrorToContext: boolean;
|
|
@@ -953,9 +954,9 @@ interface Endpoints {
|
|
|
953
954
|
transcribe?: string;
|
|
954
955
|
/**
|
|
955
956
|
* Form submission endpoint. Default: `'/ai/agent/submit-form'`. When any form
|
|
956
|
-
* (a
|
|
957
|
-
* captured values here (fire-and-forget), keyed by the same `visitorId` +
|
|
958
|
-
* `
|
|
957
|
+
* (a pre-chat lead capture, a CSAT survey, etc.) is completed, the widget POSTs
|
|
958
|
+
* the captured values here (fire-and-forget), keyed by the same `visitorId` +
|
|
959
|
+
* `conversationId` the conversation uses; the payload carries `formId` + `trigger`
|
|
959
960
|
* so the backend can route. Optional: a backend that doesn't implement it just
|
|
960
961
|
* 404s and the submission is ignored.
|
|
961
962
|
*/
|
|
@@ -965,7 +966,7 @@ interface Endpoints {
|
|
|
965
966
|
/**
|
|
966
967
|
* The three composing roots: raw input ({@link ChatWidgetOptions}),
|
|
967
968
|
* post-normalisation runtime shape ({@link ResolvedOptions}), and the
|
|
968
|
-
* subset the server can push back via `/start-
|
|
969
|
+
* subset the server can push back via `/start-conversation` ({@link
|
|
969
970
|
* ServerConfig}).
|
|
970
971
|
*
|
|
971
972
|
* Internal modules always depend on `ResolvedOptions`. The raw shape
|
|
@@ -994,7 +995,7 @@ interface ChatWidgetOptions {
|
|
|
994
995
|
/**
|
|
995
996
|
* Stable identifier for this widget instance. Use when mounting more
|
|
996
997
|
* than one widget on the same page (different deployments, different
|
|
997
|
-
* targets). Isolates client-storage namespaces (visitorId, active
|
|
998
|
+
* targets). Isolates client-storage namespaces (visitorId, active conversationId,
|
|
998
999
|
* cached userPrefs). Default: `"default"`.
|
|
999
1000
|
*/
|
|
1000
1001
|
widgetId?: string;
|
|
@@ -1140,7 +1141,7 @@ interface ResolvedOptions {
|
|
|
1140
1141
|
onError?: ChatWidgetOptions["onError"];
|
|
1141
1142
|
}
|
|
1142
1143
|
/**
|
|
1143
|
-
* Shape of the server-pushed `widget` object in `
|
|
1144
|
+
* Shape of the server-pushed `widget` object in `StartConversationResponse`.
|
|
1144
1145
|
*
|
|
1145
1146
|
* Matches a subset of {@link ChatWidgetOptions} — anything the server can
|
|
1146
1147
|
* reasonably dictate (UI, behaviour, routing). Callbacks (`onMessage` etc.)
|
|
@@ -1248,7 +1249,7 @@ interface EventMap {
|
|
|
1248
1249
|
clear: void;
|
|
1249
1250
|
/** User picked a chat from the history pane / sidebar. */
|
|
1250
1251
|
selectChat: {
|
|
1251
|
-
|
|
1252
|
+
conversationId: string;
|
|
1252
1253
|
};
|
|
1253
1254
|
/** User clicked a suggested-message chip. */
|
|
1254
1255
|
suggestion: {
|
|
@@ -1307,18 +1308,18 @@ interface EventMap {
|
|
|
1307
1308
|
/** An unhandled error occurred somewhere in the transport or UI. */
|
|
1308
1309
|
error: unknown;
|
|
1309
1310
|
/** Connect bootstrap succeeded. Payload is the typed server response. */
|
|
1310
|
-
|
|
1311
|
+
conversationStarted: StartConversationResponse;
|
|
1311
1312
|
/**
|
|
1312
1313
|
* Server rebound the `visitorId` — e.g. the client-minted id
|
|
1313
1314
|
* conflicted with an existing record, was expired, or otherwise
|
|
1314
1315
|
* rejected, and the server returned a fresh one in the
|
|
1315
|
-
* `/start-
|
|
1316
|
+
* `/start-conversation` response. The widget has already adopted the new
|
|
1316
1317
|
* id and persisted it; this event is informational so host pages
|
|
1317
1318
|
* can re-link analytics / external systems that pinned the
|
|
1318
1319
|
* previous value.
|
|
1319
1320
|
*
|
|
1320
1321
|
* `reason` is the server's explanation, when provided
|
|
1321
|
-
* (`rebind.visitorId` in the start-
|
|
1322
|
+
* (`rebind.visitorId` in the start-conversation response). Common values:
|
|
1322
1323
|
* `"conflict"` / `"expired"` / `"invalid"`. May be `undefined` if
|
|
1323
1324
|
* the server didn't include a `rebind` block.
|
|
1324
1325
|
*/
|
|
@@ -1328,12 +1329,12 @@ interface EventMap {
|
|
|
1328
1329
|
reason?: string;
|
|
1329
1330
|
};
|
|
1330
1331
|
/**
|
|
1331
|
-
* Server rebound the `
|
|
1332
|
+
* Server rebound the `conversationId` — same shape and semantics as
|
|
1332
1333
|
* `visitorRebound` but for the conversation-thread id. Fires when
|
|
1333
|
-
* the server's response carries a different `
|
|
1334
|
+
* the server's response carries a different `conversationId` than the
|
|
1334
1335
|
* client sent.
|
|
1335
1336
|
*/
|
|
1336
|
-
|
|
1337
|
+
conversationRebound: {
|
|
1337
1338
|
previous: string;
|
|
1338
1339
|
current: string;
|
|
1339
1340
|
reason?: string;
|
|
@@ -1447,7 +1448,7 @@ interface ChatWidgetInstance {
|
|
|
1447
1448
|
expand: () => void;
|
|
1448
1449
|
/**
|
|
1449
1450
|
* Open the widget in a new browser tab at `behavior.popOutUrl`
|
|
1450
|
-
* (mount option / start-
|
|
1451
|
+
* (mount option / start-conversation-pushable), or the brand's
|
|
1451
1452
|
* `BRAND.standaloneUrl` build-time default. Carries the active
|
|
1452
1453
|
* `chat` + `widgetId` as query params. No-ops when the resolved
|
|
1453
1454
|
* URL is empty.
|
|
@@ -1463,7 +1464,7 @@ interface ChatWidgetInstance {
|
|
|
1463
1464
|
* Subscribe to a lifecycle event. Returns an `off` function. See
|
|
1464
1465
|
* {@link EventMap} for the full set + payload shapes — currently
|
|
1465
1466
|
* `open | close | message | error | expand | fullscreen | popOut |
|
|
1466
|
-
*
|
|
1467
|
+
* conversationStarted | localeChange`.
|
|
1467
1468
|
*/
|
|
1468
1469
|
on: <E extends EventName>(name: E, fn: (payload: EventMap[E]) => void) => () => void;
|
|
1469
1470
|
/**
|
|
@@ -1484,7 +1485,7 @@ interface ChatWidgetInstance {
|
|
|
1484
1485
|
* ```
|
|
1485
1486
|
*/
|
|
1486
1487
|
setUserContext: (userContext: UserContext) => void;
|
|
1487
|
-
/** 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. */
|
|
1488
1489
|
clearUserContext: () => void;
|
|
1489
1490
|
/**
|
|
1490
1491
|
* Set / merge the host-asserted page/visit context (`area`, `url`, `path`,
|
|
@@ -1498,7 +1499,7 @@ interface ChatWidgetInstance {
|
|
|
1498
1499
|
* ```
|
|
1499
1500
|
*/
|
|
1500
1501
|
setPageContext: (pageContext: PageContext) => void;
|
|
1501
|
-
/** Clear the page/visit context and re-start-
|
|
1502
|
+
/** Clear the page/visit context and re-start-conversation. */
|
|
1502
1503
|
clearPageContext: () => void;
|
|
1503
1504
|
/**
|
|
1504
1505
|
* Set the runtime log level. Accepts `"off"` / `"error"` / `"warn"` /
|