@helpai/elements 1.1.13 → 1.1.15
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 +4 -3
- package/configurator.mjs +1 -1
- package/elements-web-component.esm.js +22 -22
- package/elements-web-component.esm.js.map +3 -3
- package/elements.cjs.js +22 -22
- package/elements.cjs.js.map +3 -3
- package/elements.esm.js +22 -22
- package/elements.esm.js.map +3 -3
- package/elements.js +26 -26
- package/elements.js.map +3 -3
- package/index.d.ts +222 -418
- package/index.mjs +5 -5
- package/loader.js +1 -1
- package/package.json +1 -1
- package/schema.d.ts +32 -24
- package/schema.json +25 -20
- package/schema.mjs +1 -1
- package/web-component.mjs +5 -5
package/index.d.ts
CHANGED
|
@@ -41,7 +41,7 @@ interface ClientStorage {
|
|
|
41
41
|
* populated {@link Strings} map. UI components then read `strings.send` as a
|
|
42
42
|
* normal property access — no per-render lookup, no per-render allocation.
|
|
43
43
|
*/
|
|
44
|
-
type StringKey = "launcherOpen" | "launcherLabel" | "panelTitle" | "composerPlaceholder" | "send" | "stop" | "attach" | "micStart" | "micStop" | "micUnsupported" | "expand" | "collapse" | "fullscreen" | "exitFullscreen" | "resizeHandle" | "scrollToBottom" | "close" | "moreActions" | "soundOn" | "soundOff" | "language" | "theme" | "themeAuto" | "themeLight" | "themeDark" | "textSize" | "textSizeSmall" | "textSizeNormal" | "textSizeLarge" | "history" | "historyTitle" | "historyEmpty" | "historyLoading" | "historyBack" | "historyContinue" | "loadMoreConversations" | "conversationLoading" | "loadPreviousMessages" | "conversationClosed" | "startNewConversation" | "talkToOperator" | "connectingOperator" | "noOperatorAvailable" | "chattingWithOperator" | "cancelOperatorRequest" | "dateToday" | "dateYesterday" | "dateLastWeek" | "dateOlder" | "newConversation" | "dropZone" | "attachmentTooLarge" | "attachmentTooMany" | "attachmentMimeRejected" | "errorRetry" | "errorGeneric" | "errorRateLimited" | "loading" | "thinking" | "thoughts" | "toolResult" | "sources" | "feedbackUp" | "feedbackDown" | "feedbackThanks" | "copy" | "copied" | "collapseSidebar" | "expandSidebar" | "formSubmit" | "formSkip" | "formSubmitted" | "formSkipped" | "formFillOut" | "formRequired" | "formInvalidEmail" | "formInvalidTel" | "formInvalidUrl" | "formInvalidNumber" | "formTooShort" | "formTooLong" | "formNumberTooSmall" | "formNumberTooLarge" | "formPatternMismatch" | "formChooseAtLeast" | "formChooseAtMost" | "formOther" | "formOtherPlaceholder" | "inputRequired" | "inputBadge" | "inputAnswered" | "inputSkipped" | "inputSubmit" | "inputSubmitHint" | "inputSkip" | "showOptions" | "hideOptions" | "qtypeText" | "qtypeEmail" | "qtypePhone" | "qtypeNumber" | "qtypeDate" | "qtypeChooseOne" | "qtypeChooseAny" | "qtypeBoolean" | "confirmYes" | "confirmNo" | "approve" | "reject" | "approvalPrompt" | "approvalBody" | "approvalYourResponse" | "approvalEditHint" | "approvalSubmitting" | "edit" | "toolParameters" | "statusAwaiting" | "statusResponded" | "statusCompleted" | "statusDenied" | "statusError" | "statusRunning" | "statusSuperseded" | "tabHome" | "tabConversations" | "tabHelp" | "tabNews" | "modulesEmpty" | "moduleBack" | "contentLoading" | "homeGreeting" | "homeGreetingNamed" | "homeGreetingLead" | "homeSearchPlaceholder" | "homeContentTitle" | "homeStatus" | "helpTitle" | "helpSearchPlaceholder" | "helpEmpty" | "helpLoading" | "helpSearchEmpty" | "newsTitle" | "newsEmpty" | "newsLoading" | "newsBack" | "newsPublishedAt";
|
|
44
|
+
type StringKey = "launcherOpen" | "launcherLabel" | "panelTitle" | "composerPlaceholder" | "send" | "stop" | "attach" | "micStart" | "micStop" | "micUnsupported" | "expand" | "collapse" | "fullscreen" | "exitFullscreen" | "popOut" | "resizeHandle" | "scrollToBottom" | "close" | "moreActions" | "soundOn" | "soundOff" | "language" | "theme" | "themeAuto" | "themeLight" | "themeDark" | "textSize" | "textSizeSmall" | "textSizeNormal" | "textSizeLarge" | "history" | "historyTitle" | "historyEmpty" | "historyLoading" | "historyBack" | "historyContinue" | "loadMoreConversations" | "conversationLoading" | "loadPreviousMessages" | "conversationClosed" | "startNewConversation" | "talkToOperator" | "connectingOperator" | "noOperatorAvailable" | "chattingWithOperator" | "cancelOperatorRequest" | "dateToday" | "dateYesterday" | "dateLastWeek" | "dateOlder" | "newConversation" | "dropZone" | "attachmentTooLarge" | "attachmentTooMany" | "attachmentMimeRejected" | "errorRetry" | "errorGeneric" | "errorRateLimited" | "loading" | "thinking" | "thoughts" | "toolResult" | "sources" | "feedbackUp" | "feedbackDown" | "feedbackThanks" | "copy" | "copied" | "collapseSidebar" | "expandSidebar" | "formSubmit" | "formSkip" | "formSubmitted" | "formSkipped" | "formFillOut" | "formRequired" | "formInvalidEmail" | "formInvalidTel" | "formInvalidUrl" | "formInvalidNumber" | "formTooShort" | "formTooLong" | "formNumberTooSmall" | "formNumberTooLarge" | "formPatternMismatch" | "formChooseAtLeast" | "formChooseAtMost" | "formOther" | "formOtherPlaceholder" | "inputRequired" | "inputBadge" | "inputAnswered" | "inputSkipped" | "inputSubmit" | "inputSubmitHint" | "inputSkip" | "showOptions" | "hideOptions" | "qtypeText" | "qtypeEmail" | "qtypePhone" | "qtypeNumber" | "qtypeDate" | "qtypeChooseOne" | "qtypeChooseAny" | "qtypeBoolean" | "confirmYes" | "confirmNo" | "approve" | "reject" | "approvalPrompt" | "approvalBody" | "approvalYourResponse" | "approvalEditHint" | "approvalSubmitting" | "edit" | "toolParameters" | "statusAwaiting" | "statusResponded" | "statusCompleted" | "statusDenied" | "statusError" | "statusRunning" | "statusSuperseded" | "tabHome" | "tabConversations" | "tabHelp" | "tabNews" | "modulesEmpty" | "moduleBack" | "contentLoading" | "homeGreeting" | "homeGreetingNamed" | "homeGreetingLead" | "homeSearchPlaceholder" | "homeContentTitle" | "homeStatus" | "helpTitle" | "helpSearchPlaceholder" | "helpEmpty" | "helpLoading" | "helpSearchEmpty" | "newsTitle" | "newsEmpty" | "newsLoading" | "newsBack" | "newsPublishedAt";
|
|
45
45
|
/** A partial map for one locale — what overrides look like on the wire. */
|
|
46
46
|
type LocaleStrings = Partial<Record<StringKey, string>>;
|
|
47
47
|
/**
|
|
@@ -120,13 +120,14 @@ type ResponseMode = "streaming" | "buffered";
|
|
|
120
120
|
* - `clear` — Start a new conversation (compose icon).
|
|
121
121
|
* - `expand` — Toggle `normal` ↔ `expanded` (1.5× panel).
|
|
122
122
|
* - `fullscreen` — Toggle `normal` ↔ `fullscreen` (viewport fill).
|
|
123
|
+
* - `popOut` — Open the active conversation in a dedicated tab.
|
|
123
124
|
* - `sound` — Toggle notification sounds + haptics on/off (switch-style).
|
|
124
125
|
* - `language` — Switch the UI locale at runtime.
|
|
125
126
|
* - `theme` — Cycle `auto` / `light` / `dark`.
|
|
126
127
|
* - `textSize` — Cycle `normal` / `large` / `small`.
|
|
127
128
|
* - `close` — Close the floating panel.
|
|
128
129
|
*/
|
|
129
|
-
type ActionName = "clear" | "expand" | "fullscreen" | "sound" | "history" | "language" | "theme" | "textSize" | "close";
|
|
130
|
+
type ActionName = "clear" | "expand" | "fullscreen" | "popOut" | "sound" | "history" | "language" | "theme" | "textSize" | "close";
|
|
130
131
|
/**
|
|
131
132
|
* The header's enabled actions. Unlisted actions are hidden; order is
|
|
132
133
|
* irrelevant. Per-mode defaults (`DEFAULT_ACTIONS_BY_MODE`) pick a sensible
|
|
@@ -718,6 +719,8 @@ interface BehaviorOptions {
|
|
|
718
719
|
disableMessageFeedback?: boolean;
|
|
719
720
|
/** Auto-send a suggestion chip's text on tap. Unset/`false` = fill the composer to edit (default). */
|
|
720
721
|
autoSendSuggestions?: boolean;
|
|
722
|
+
/** URL opened by the `popOut` header action. */
|
|
723
|
+
popOutUrl?: string;
|
|
721
724
|
}
|
|
722
725
|
/**
|
|
723
726
|
* Section: panel header actions — the enabled set (`history`/`close` buttons +
|
|
@@ -772,7 +775,8 @@ interface FooterOptions {
|
|
|
772
775
|
* and the agent purely as **informational context** — never as an auth
|
|
773
776
|
* credential. The widget runs on third-party sites (e.g. `example.com`); some
|
|
774
777
|
* have their own login, others are guest-only. We don't register or
|
|
775
|
-
* authenticate these users (
|
|
778
|
+
* authenticate these users (browser access always identifies a deployment;
|
|
779
|
+
* a public key is optional for intentional guest mode).
|
|
776
780
|
*
|
|
777
781
|
* `id` / `email` / `name` are recognised fields used for the Home greeting and
|
|
778
782
|
* transcripts; any extra scalar fields become custom context the agent can use
|
|
@@ -898,7 +902,9 @@ interface ResolvedTracking {
|
|
|
898
902
|
//#region src/core/config/types/widget.d.ts
|
|
899
903
|
/**
|
|
900
904
|
* Raw options passed to {@link mount}, {@link init}, the Web Component, or
|
|
901
|
-
* the `<script data-*>` auto-boot path.
|
|
905
|
+
* the `<script data-*>` auto-boot path. The public `mount()` / `init()`
|
|
906
|
+
* boundary requires `aiAgentDeploymentId`; parsers keep it optional while
|
|
907
|
+
* assembling an attribute snapshot so a missing value can fail at that boundary.
|
|
902
908
|
*
|
|
903
909
|
* Two layers:
|
|
904
910
|
*
|
|
@@ -922,9 +928,9 @@ interface ChatWidgetOptions {
|
|
|
922
928
|
* cached userPrefs). Default: `"default"`.
|
|
923
929
|
*/
|
|
924
930
|
widgetId?: string;
|
|
925
|
-
/**
|
|
931
|
+
/** Deployment public key (`agent_pk_...`). Sent as `x-public-key` when present. */
|
|
926
932
|
publicKey?: string;
|
|
927
|
-
/** Deployment ID (UUID).
|
|
933
|
+
/** Deployment ID (UUID). Required by every public mount and sent as `x-ai-agent-deployment-id`. */
|
|
928
934
|
aiAgentDeploymentId?: string;
|
|
929
935
|
/**
|
|
930
936
|
* MAIN site origin (no trailing slash, e.g. `https://help.ai`). The API
|
|
@@ -936,7 +942,7 @@ interface ChatWidgetOptions {
|
|
|
936
942
|
/**
|
|
937
943
|
* Agent-API base (no trailing slash) — set it when the
|
|
938
944
|
* `module-help-ai-agent-api` service is reached DIRECTLY (a standalone
|
|
939
|
-
* local module, e.g. `http://localhost:
|
|
945
|
+
* local module, e.g. `http://localhost:3111`) instead of through the
|
|
940
946
|
* edge. Routes attach as-is (`${agentApiBaseUrl}/pai/handshake`).
|
|
941
947
|
* Precedence: this option > derived from the main origin
|
|
942
948
|
* (`${baseUrl}/api/agent`). Not server-pushable — the handshake already
|
|
@@ -947,7 +953,7 @@ interface ChatWidgetOptions {
|
|
|
947
953
|
* Data-API base (no trailing slash) — the `module-help-ai-data-api`
|
|
948
954
|
* service serving content, form definitions, and form submissions under
|
|
949
955
|
* `/pai/*` (`content`, `bootstrap`, `submit-form`).
|
|
950
|
-
* Set it for a standalone local module (e.g. `http://localhost:
|
|
956
|
+
* Set it for a standalone local module (e.g. `http://localhost:3105`).
|
|
951
957
|
* Precedence: this option > server-pushed `config.dataApiBaseUrl` > derived
|
|
952
958
|
* from the main origin (`${baseUrl}/api/data`, e.g.
|
|
953
959
|
* `https://help.ai/api/data`).
|
|
@@ -1031,6 +1037,8 @@ interface ResolvedOptions {
|
|
|
1031
1037
|
enableMessageFeedback: boolean;
|
|
1032
1038
|
/** Auto-send a suggestion chip's text on tap (vs. filling the composer to edit). Default `false`. */
|
|
1033
1039
|
autoSendSuggestions: boolean;
|
|
1040
|
+
/** URL opened by the `popOut` action. Absent means the action is hidden. */
|
|
1041
|
+
popOutUrl?: string;
|
|
1034
1042
|
features: ResolvedFeatures;
|
|
1035
1043
|
/** Resolved event-driven forms — ordered list + trigger index. */
|
|
1036
1044
|
forms: ResolvedForms;
|
|
@@ -1102,42 +1110,6 @@ interface ResolvedOptions {
|
|
|
1102
1110
|
onClose?: ChatWidgetOptions["onClose"];
|
|
1103
1111
|
onError?: ChatWidgetOptions["onError"];
|
|
1104
1112
|
}
|
|
1105
|
-
/**
|
|
1106
|
-
* Shape of the server-pushed `config` object in `HandshakeResponse`.
|
|
1107
|
-
*
|
|
1108
|
-
* Matches a subset of {@link ChatWidgetOptions} — anything the server can
|
|
1109
|
-
* reasonably dictate (UI, behaviour, routing). Callbacks (`onMessage` etc.)
|
|
1110
|
-
* and the public key are deliberately excluded — those are client concerns.
|
|
1111
|
-
*
|
|
1112
|
-
* Form definitions no longer ride this config: the widget fetches them from
|
|
1113
|
-
* the data-API (`GET /pai/bootstrap`). A stale backend still pushing
|
|
1114
|
-
* `config.forms` is ignored.
|
|
1115
|
-
*/
|
|
1116
|
-
interface ServerConfig$1 {
|
|
1117
|
-
/** Data-API base override — adopted only when the host didn't set one. */
|
|
1118
|
-
dataApiBaseUrl?: string;
|
|
1119
|
-
/**
|
|
1120
|
-
* Storage-schema version — the deployment-owned force-reset lever, pushed ONLY
|
|
1121
|
-
* via the handshake (deliberately not an embed attribute / `init` option).
|
|
1122
|
-
* Pushing a new value abandons every client's prior storage namespace
|
|
1123
|
-
* (visitor id, conversation, prefs, panel state, caches) on next load. The
|
|
1124
|
-
* widget stashes it and the next mount folds `.v<version>` into every key.
|
|
1125
|
-
*/
|
|
1126
|
-
storageVersion?: string;
|
|
1127
|
-
presentation?: PresentationOptions;
|
|
1128
|
-
behavior?: BehaviorOptions;
|
|
1129
|
-
theme?: ThemePreference | ThemeOverrides;
|
|
1130
|
-
launcher?: LauncherOptions;
|
|
1131
|
-
header?: HeaderOptions;
|
|
1132
|
-
composer?: ComposerOptions;
|
|
1133
|
-
feedback?: FeedbackOptions;
|
|
1134
|
-
i18n?: I18nOptions;
|
|
1135
|
-
footer?: FooterOptions;
|
|
1136
|
-
features?: FeatureFlags;
|
|
1137
|
-
modules?: ModulesOptions;
|
|
1138
|
-
tracking?: TrackingOptions;
|
|
1139
|
-
endpoints?: Endpoints;
|
|
1140
|
-
}
|
|
1141
1113
|
//#endregion
|
|
1142
1114
|
//#region src/core/logger.d.ts
|
|
1143
1115
|
/**
|
|
@@ -1173,362 +1145,6 @@ interface LogEntry {
|
|
|
1173
1145
|
payload?: unknown;
|
|
1174
1146
|
}
|
|
1175
1147
|
//#endregion
|
|
1176
|
-
//#region src/core/persistence.d.ts
|
|
1177
|
-
/** Drag-resized panel dimensions. Persisted only when resize is enabled. */
|
|
1178
|
-
interface WidgetSize {
|
|
1179
|
-
width: number;
|
|
1180
|
-
height: number;
|
|
1181
|
-
}
|
|
1182
|
-
/**
|
|
1183
|
-
* User-changeable preferences. Sent to the backend on every request as a
|
|
1184
|
-
* `userPrefs` field so the server can detect drift (e.g. user changed
|
|
1185
|
-
* locale on another tab) and reconcile.
|
|
1186
|
-
*
|
|
1187
|
-
* Every field is optional — an unset key inherits the server / page-owner
|
|
1188
|
-
* default. Empty object `{}` means "no preference recorded yet."
|
|
1189
|
-
*/
|
|
1190
|
-
interface UserPrefs {
|
|
1191
|
-
/** BCP-47 tag picked from the language switcher. */
|
|
1192
|
-
locale?: string;
|
|
1193
|
-
/** Drag-resized panel dimensions. */
|
|
1194
|
-
widgetSize?: WidgetSize;
|
|
1195
|
-
/** Sound on/off toggle (icon button). */
|
|
1196
|
-
soundMuted?: boolean;
|
|
1197
|
-
/** Theme picked from the theme switcher. */
|
|
1198
|
-
themeMode?: "auto" | "light" | "dark";
|
|
1199
|
-
/** Text size picked from the text-size switcher. */
|
|
1200
|
-
textSize?: "small" | "normal" | "large";
|
|
1201
|
-
}
|
|
1202
|
-
//#endregion
|
|
1203
|
-
//#region src/stream/types.d.ts
|
|
1204
|
-
/** A 👍/👎 reaction on a rateable (assistant/operator) message; `null` clears a prior choice. */
|
|
1205
|
-
type FeedbackValue = "up" | "down" | null;
|
|
1206
|
-
//#endregion
|
|
1207
|
-
//#region src/stream/protocol.d.ts
|
|
1208
|
-
/**
|
|
1209
|
-
* Who is driving replies in a conversation — the widget mirrors the backend `controlMode`.
|
|
1210
|
-
* - `ai-agent`: the AI agent answers (normal operation).
|
|
1211
|
-
* - `awaiting_operator`: operator-control requested, the AI no longer answers — the turn routes to the
|
|
1212
|
-
* operator — while waiting in the operator queue.
|
|
1213
|
-
* - `operator`: a workspace operator took over and is replying.
|
|
1214
|
-
*
|
|
1215
|
-
* Carried on `HandshakeResponse.controlState`, `LoadConversationResponse.controlState` (resume +
|
|
1216
|
-
* history-switch), and the `data-control-state` stream part (on the reply stream). Absent / unknown →
|
|
1217
|
-
* treated as `"ai-agent"`.
|
|
1218
|
-
*/
|
|
1219
|
-
type ControlMode = "ai-agent" | "awaiting_operator" | "operator";
|
|
1220
|
-
/**
|
|
1221
|
-
* The control-state snapshot the widget reads to render composer/typing/banner state. The optional
|
|
1222
|
-
* `operatorAvailable` (set on the operator-request response + the awaiting terminal part) tells the
|
|
1223
|
-
* widget whether to show "connecting…" or the async-capture ("leave your details") copy.
|
|
1224
|
-
*/
|
|
1225
|
-
interface ControlState {
|
|
1226
|
-
controlMode: ControlMode;
|
|
1227
|
-
/** Monotonic state version: orders received snapshots and fences request/cancel retries to their observed cycle. */
|
|
1228
|
-
controlRevision?: number;
|
|
1229
|
-
/**
|
|
1230
|
-
* The operator's 2-letter initials (operator mode only) — shown in the bubble chrome + banner. The
|
|
1231
|
-
* visitor never sees the full name (privacy); the backend derives the initials. `assignedOperatorId`
|
|
1232
|
-
* also rides the wire but the widget doesn't render it, so it isn't modeled here.
|
|
1233
|
-
*/
|
|
1234
|
-
assignedOperatorInitials?: string;
|
|
1235
|
-
/** Whether anyone was in the operator pool when operator-control was requested (awaiting mode advisory). */
|
|
1236
|
-
operatorAvailable?: boolean;
|
|
1237
|
-
}
|
|
1238
|
-
/** One-shot bot persona shown in the panel header. */
|
|
1239
|
-
interface ConversationAgent {
|
|
1240
|
-
name: string;
|
|
1241
|
-
/** Image URL or data URI. When omitted, initials render from `name`. */
|
|
1242
|
-
avatar?: string;
|
|
1243
|
-
/** Subtitle ("AI Assistant", "Support team", …). */
|
|
1244
|
-
title?: string;
|
|
1245
|
-
/** Presence indicator. Default: `'online'`. */
|
|
1246
|
-
status?: "online" | "away" | "offline";
|
|
1247
|
-
}
|
|
1248
|
-
/** A clickable quick-reply chip. */
|
|
1249
|
-
interface ConversationSuggestion {
|
|
1250
|
-
id: string;
|
|
1251
|
-
/** What the chip displays. */
|
|
1252
|
-
label: string;
|
|
1253
|
-
/** What actually gets sent when clicked. Defaults to `label`. */
|
|
1254
|
-
text?: string;
|
|
1255
|
-
}
|
|
1256
|
-
/** Welcome payload pushed into the message list on first open. */
|
|
1257
|
-
interface ConversationWelcome {
|
|
1258
|
-
messages?: Array<{
|
|
1259
|
-
id: string;
|
|
1260
|
-
role: "assistant" | "system";
|
|
1261
|
-
text: string;
|
|
1262
|
-
}>;
|
|
1263
|
-
suggestions?: ConversationSuggestion[];
|
|
1264
|
-
}
|
|
1265
|
-
/**
|
|
1266
|
-
* Response from `POST /pai/handshake` — the widget's one mount-time
|
|
1267
|
-
* round-trip. Deliberately LIGHT: identity + deployment surface only
|
|
1268
|
-
* (config, agent persona, welcome, page-mode site/blocks, userPrefs).
|
|
1269
|
-
* The conversation THREAD is a separate, lazily-fetched read
|
|
1270
|
-
* (`GET /conversation`) that only runs once the widget is activated
|
|
1271
|
-
* (opened) — a closed launcher costs the page exactly one request.
|
|
1272
|
-
*
|
|
1273
|
-
* The `userPrefs` field (when present) is the server's authoritative
|
|
1274
|
-
* copy of per-visitor preferences — the client should adopt it and update
|
|
1275
|
-
* its local cache. Lets a user picking French on their phone see the
|
|
1276
|
-
* widget in French when they open it on their laptop (assuming the same
|
|
1277
|
-
* `visitorId`, e.g. via authenticated conversation — out of scope for v1).
|
|
1278
|
-
*/
|
|
1279
|
-
interface HandshakeResponse$1 {
|
|
1280
|
-
/**
|
|
1281
|
-
* Public runtime conversation id. The widget mints this UUIDv7 and the backend
|
|
1282
|
-
* validates that it belongs to the public deployment + visitor.
|
|
1283
|
-
*/
|
|
1284
|
-
conversationId: string;
|
|
1285
|
-
visitorId?: string;
|
|
1286
|
-
/** Bot persona in the panel header (name, avatar, status). */
|
|
1287
|
-
agent?: ConversationAgent;
|
|
1288
|
-
/** Initial assistant messages + quick-reply chips. */
|
|
1289
|
-
welcome?: ConversationWelcome;
|
|
1290
|
-
/**
|
|
1291
|
-
* Deployment-wide widget configuration the dashboard admin saved
|
|
1292
|
-
* (mode / theme / launcher / actions / composer / features / …).
|
|
1293
|
-
* Client adopts as defaults; customer's `init({...})` still wins
|
|
1294
|
-
* per-field. Same for every visitor of this deployment.
|
|
1295
|
-
*/
|
|
1296
|
-
config?: ServerConfig$1;
|
|
1297
|
-
/** Page-mode site config (logo, title). Backend ships it whenever the deployment renders the page-shell sidebar. */
|
|
1298
|
-
site?: Record<string, unknown>;
|
|
1299
|
-
/** Page-mode sidebar blocks (navigation, link cards). Backend ships it whenever the deployment renders the page-shell sidebar. */
|
|
1300
|
-
blocks?: Record<string, unknown>;
|
|
1301
|
-
/** Current control state — seeds the composer/typing/banner state on connect. Absent → `ai-agent`. */
|
|
1302
|
-
controlState?: ControlState;
|
|
1303
|
-
/**
|
|
1304
|
-
* Server's authoritative copy of the visitor's preferences. When present,
|
|
1305
|
-
* client adopts it (overrides local cache) and re-applies it to the UI
|
|
1306
|
-
* (locale, panel size, sound mute). Absent → client keeps its cache.
|
|
1307
|
-
*/
|
|
1308
|
-
userPrefs?: UserPrefs;
|
|
1309
|
-
/**
|
|
1310
|
-
* Optional rebind metadata. When the server returns a `visitorId` /
|
|
1311
|
-
* `conversationId` different from what the client sent, this block tells
|
|
1312
|
-
* the client WHY — useful for telemetry and the `visitorRebound` /
|
|
1313
|
-
* `conversationRebound` events fired into the host page. Server is free to
|
|
1314
|
-
* omit it: the client detects rebinding by comparing request vs
|
|
1315
|
-
* response ids regardless.
|
|
1316
|
-
*
|
|
1317
|
-
* Common reasons: `"conflict"` (the id collided with an existing
|
|
1318
|
-
* record), `"expired"` (the id is too old to be re-used), `"invalid"`
|
|
1319
|
-
* (malformed / not a UUIDv7). Custom strings are passed through to
|
|
1320
|
-
* listeners verbatim.
|
|
1321
|
-
*/
|
|
1322
|
-
rebind?: {
|
|
1323
|
-
visitorId?: string;
|
|
1324
|
-
conversationId?: string;
|
|
1325
|
-
};
|
|
1326
|
-
}
|
|
1327
|
-
//#endregion
|
|
1328
|
-
//#region src/core/events.d.ts
|
|
1329
|
-
/**
|
|
1330
|
-
* Payload shape per event. Keyed by event name; use `void` for events that
|
|
1331
|
-
* carry no data.
|
|
1332
|
-
*
|
|
1333
|
-
* **Every user-visible action fires here.** Subscribe via
|
|
1334
|
-
* `chat.on("eventName", fn)` to add analytics, side effects, or audit
|
|
1335
|
-
* trails without forking the widget. The same names also stream to the
|
|
1336
|
-
* structured logger at `info` level when `debug` is enabled.
|
|
1337
|
-
*/
|
|
1338
|
-
interface EventMap {
|
|
1339
|
-
/** Panel opened (floating / modal / drawer). */
|
|
1340
|
-
open: void;
|
|
1341
|
-
/** Panel closed. */
|
|
1342
|
-
close: void;
|
|
1343
|
-
/** Expanded mode toggled (1.5× size). Payload is the new state. */
|
|
1344
|
-
expand: boolean;
|
|
1345
|
-
/** Fullscreen mode toggled. Payload is the new state. */
|
|
1346
|
-
fullscreen: boolean;
|
|
1347
|
-
/** End-user dragged the resize grip — payload is the resolved size. */
|
|
1348
|
-
resize: {
|
|
1349
|
-
width: number;
|
|
1350
|
-
height: number;
|
|
1351
|
-
};
|
|
1352
|
-
/** A message was exchanged. Fires for user, assistant, and operator messages. */
|
|
1353
|
-
message: {
|
|
1354
|
-
role: string;
|
|
1355
|
-
text: string;
|
|
1356
|
-
};
|
|
1357
|
-
/** User submitted a message (fires before the request is sent). */
|
|
1358
|
-
send: {
|
|
1359
|
-
text: string;
|
|
1360
|
-
attachmentCount: number;
|
|
1361
|
-
};
|
|
1362
|
-
/** User cancelled an in-flight stream. */
|
|
1363
|
-
stop: void;
|
|
1364
|
-
/** Clear / new-conversation requested. */
|
|
1365
|
-
clear: void;
|
|
1366
|
-
/** User picked a chat from the history pane / sidebar. */
|
|
1367
|
-
selectConversation: {
|
|
1368
|
-
conversationId: string;
|
|
1369
|
-
};
|
|
1370
|
-
/** User clicked a suggested-message chip. */
|
|
1371
|
-
suggestion: {
|
|
1372
|
-
text: string;
|
|
1373
|
-
};
|
|
1374
|
-
/** History pane toggled. Payload is the resulting view. */
|
|
1375
|
-
toggleHistory: {
|
|
1376
|
-
view: "chat" | "history";
|
|
1377
|
-
};
|
|
1378
|
-
/** A form (intake, CSAT, …) was completed or skipped. */
|
|
1379
|
-
formSubmit: {
|
|
1380
|
-
formId: string;
|
|
1381
|
-
values: Record<string, string>;
|
|
1382
|
-
skipped: boolean;
|
|
1383
|
-
};
|
|
1384
|
-
/** User answered an ask-questions tool request (re-POST follows). */
|
|
1385
|
-
toolResult: {
|
|
1386
|
-
toolCallId: string;
|
|
1387
|
-
};
|
|
1388
|
-
/** User approved / rejected a gated tool call (re-POST follows). */
|
|
1389
|
-
toolDecision: {
|
|
1390
|
-
toolCallId: string;
|
|
1391
|
-
approved: boolean;
|
|
1392
|
-
};
|
|
1393
|
-
/**
|
|
1394
|
-
* User gave feedback on a rateable reply (AI or operator). `value` is `"up"` / `"down"`, or
|
|
1395
|
-
* `null` when they cleared a prior choice. `messageId` is the backend message
|
|
1396
|
-
* id. Also POSTed best-effort to `/pai/message-feedback`; a host listener can
|
|
1397
|
-
* mirror it to analytics.
|
|
1398
|
-
*/
|
|
1399
|
-
messageFeedback: {
|
|
1400
|
-
messageId: string;
|
|
1401
|
-
value: FeedbackValue;
|
|
1402
|
-
};
|
|
1403
|
-
/** A content list (news / help / home block) rendered. */
|
|
1404
|
-
contentView: {
|
|
1405
|
-
section: string;
|
|
1406
|
-
tags?: string;
|
|
1407
|
-
count: number;
|
|
1408
|
-
};
|
|
1409
|
-
/** An article / content item was opened. */
|
|
1410
|
-
contentOpen: {
|
|
1411
|
-
contentId: string;
|
|
1412
|
-
tags?: string;
|
|
1413
|
-
};
|
|
1414
|
-
/** The help search ran. Length + hit count only — never the query text. */
|
|
1415
|
-
contentSearch: {
|
|
1416
|
-
queryLength: number;
|
|
1417
|
-
hitCount: number;
|
|
1418
|
-
};
|
|
1419
|
-
/** An opened article was read (dwell threshold passed). Fires once per open. */
|
|
1420
|
-
contentRead: {
|
|
1421
|
-
contentId: string;
|
|
1422
|
-
};
|
|
1423
|
-
/** A link inside an opened article was followed. */
|
|
1424
|
-
contentLinkClick: {
|
|
1425
|
-
contentId: string;
|
|
1426
|
-
};
|
|
1427
|
-
/** Files attached (drag-drop, file picker, paste). */
|
|
1428
|
-
attach: {
|
|
1429
|
-
count: number;
|
|
1430
|
-
totalBytes: number;
|
|
1431
|
-
};
|
|
1432
|
-
/** An attachment was removed before send. */
|
|
1433
|
-
removeAttachment: {
|
|
1434
|
-
id: string;
|
|
1435
|
-
};
|
|
1436
|
-
/** Voice recording started. */
|
|
1437
|
-
voiceStart: void;
|
|
1438
|
-
/** Voice recording stopped and was sent for transcription. */
|
|
1439
|
-
voiceStop: {
|
|
1440
|
-
durationMs: number;
|
|
1441
|
-
};
|
|
1442
|
-
/** Voice recording cancelled (e.g. user released outside the button). */
|
|
1443
|
-
voiceCancel: void;
|
|
1444
|
-
/** End-user picked a different UI locale. Payload is the new BCP-47 tag. */
|
|
1445
|
-
localeChange: string;
|
|
1446
|
-
/** End-user picked a different theme mode (`auto` / `light` / `dark`). */
|
|
1447
|
-
themeChange: ThemePreference;
|
|
1448
|
-
/** End-user picked a different text size (`small` / `normal` / `large`). */
|
|
1449
|
-
textSizeChange: TextSize;
|
|
1450
|
-
/** End-user toggled the global sound mute. */
|
|
1451
|
-
soundToggle: {
|
|
1452
|
-
muted: boolean;
|
|
1453
|
-
};
|
|
1454
|
-
/** Page-mode sidebar collapsed / expanded. */
|
|
1455
|
-
sidebarToggle: {
|
|
1456
|
-
collapsed: boolean;
|
|
1457
|
-
};
|
|
1458
|
-
/** Pre-engagement launcher callout dismissed. */
|
|
1459
|
-
calloutDismiss: void;
|
|
1460
|
-
/** An unhandled error occurred somewhere in the transport or UI. */
|
|
1461
|
-
error: unknown;
|
|
1462
|
-
/** Connect bootstrap succeeded. Payload is the typed server response. */
|
|
1463
|
-
handshake: HandshakeResponse$1;
|
|
1464
|
-
/**
|
|
1465
|
-
* Server rebound the `visitorId` — e.g. the client-minted id
|
|
1466
|
-
* conflicted with an existing record, was expired, or otherwise
|
|
1467
|
-
* rejected, and the server returned a fresh one in the
|
|
1468
|
-
* `/handshake` response. The widget has already adopted the new
|
|
1469
|
-
* id and persisted it; this event is informational so host pages
|
|
1470
|
-
* can re-link analytics / external systems that pinned the
|
|
1471
|
-
* previous value.
|
|
1472
|
-
*
|
|
1473
|
-
* `reason` is the server's explanation, when provided
|
|
1474
|
-
* (`rebind.visitorId` in the handshake response). Common values:
|
|
1475
|
-
* `"conflict"` / `"expired"` / `"invalid"`. May be `undefined` if
|
|
1476
|
-
* the server didn't include a `rebind` block.
|
|
1477
|
-
*/
|
|
1478
|
-
visitorRebound: {
|
|
1479
|
-
previous: string;
|
|
1480
|
-
current: string;
|
|
1481
|
-
reason?: string;
|
|
1482
|
-
};
|
|
1483
|
-
/**
|
|
1484
|
-
* Server rebound the `conversationId` — same shape and semantics as
|
|
1485
|
-
* `visitorRebound` but for the conversation-thread id. Fires when
|
|
1486
|
-
* the server's response carries a different `conversationId` than the
|
|
1487
|
-
* client sent.
|
|
1488
|
-
*/
|
|
1489
|
-
conversationRebound: {
|
|
1490
|
-
previous: string;
|
|
1491
|
-
current: string;
|
|
1492
|
-
reason?: string;
|
|
1493
|
-
};
|
|
1494
|
-
}
|
|
1495
|
-
type EventName = keyof EventMap;
|
|
1496
|
-
//#endregion
|
|
1497
|
-
//#region src/ui/host-mode.d.ts
|
|
1498
|
-
type HostMode = "page" | "standalone" | "inline" | "modal" | "drawer" | "fullscreen" | "expanded" | "open" | "closed";
|
|
1499
|
-
//#endregion
|
|
1500
|
-
//#region src/boot.d.ts
|
|
1501
|
-
/**
|
|
1502
|
-
* Determine what `data-mode` the host should start at — matching what App's
|
|
1503
|
-
* mount-time `useEffect` will produce on its first render. Used for the initial
|
|
1504
|
-
* paint in both entry points (and `mount()`'s iframe sizing); after that, App
|
|
1505
|
-
* owns `data-mode` for the lifetime of the instance.
|
|
1506
|
-
*
|
|
1507
|
-
* `resolveInitialPanelState` is the one source of truth for "what does the first
|
|
1508
|
-
* render look like" — App.tsx uses it too. If these two paths ever pick
|
|
1509
|
-
* different initial states, an iframe physically resizes between mount and App's
|
|
1510
|
-
* first effect (the closed→open→closed flicker this pins against).
|
|
1511
|
-
*/
|
|
1512
|
-
declare function resolveInitialHostMode(options: ResolvedOptions): HostMode;
|
|
1513
|
-
//#endregion
|
|
1514
|
-
//#region src/core/hooks.d.ts
|
|
1515
|
-
/** Wildcard that matches every widget id / every event name. */
|
|
1516
|
-
declare const HOOK_WILDCARD = "*";
|
|
1517
|
-
/**
|
|
1518
|
-
* Unified lifecycle callback signature. `data` is `unknown` — narrow it
|
|
1519
|
-
* via the `event` discriminator using {@link EventMap} if needed:
|
|
1520
|
-
*
|
|
1521
|
-
* ```ts
|
|
1522
|
-
* HelpAI.hook("*", "*", (inst, event, data) => {
|
|
1523
|
-
* if (event === "message") {
|
|
1524
|
-
* const msg = data as EventMap["message"]; // { role, text }
|
|
1525
|
-
* // ...
|
|
1526
|
-
* }
|
|
1527
|
-
* });
|
|
1528
|
-
* ```
|
|
1529
|
-
*/
|
|
1530
|
-
type HookListener = (instance: ChatWidgetInstance, event: EventName, data: unknown) => void;
|
|
1531
|
-
//#endregion
|
|
1532
1148
|
//#region src/schema/primitives.d.ts
|
|
1533
1149
|
/** A single image asset (logo, hero, icon). */
|
|
1534
1150
|
declare const assetSchema: z.ZodObject<{
|
|
@@ -1556,7 +1172,7 @@ type Link = z.infer<typeof linkSchema>;
|
|
|
1556
1172
|
declare const connectionConfigSchema: z.ZodObject<{
|
|
1557
1173
|
widgetId: z.ZodDefault<z.ZodString>;
|
|
1558
1174
|
publicKey: z.ZodOptional<z.ZodString>;
|
|
1559
|
-
aiAgentDeploymentId: z.
|
|
1175
|
+
aiAgentDeploymentId: z.ZodString;
|
|
1560
1176
|
baseUrl: z.ZodOptional<z.ZodString>;
|
|
1561
1177
|
agentApiBaseUrl: z.ZodOptional<z.ZodString>;
|
|
1562
1178
|
dataApiBaseUrl: z.ZodOptional<z.ZodString>;
|
|
@@ -1651,6 +1267,7 @@ declare const widgetSettingsSchema: z.ZodObject<{
|
|
|
1651
1267
|
showSources: z.ZodDefault<z.ZodBoolean>;
|
|
1652
1268
|
disableMessageFeedback: z.ZodDefault<z.ZodBoolean>;
|
|
1653
1269
|
autoSendSuggestions: z.ZodDefault<z.ZodBoolean>;
|
|
1270
|
+
popOutUrl: z.ZodOptional<z.ZodString>;
|
|
1654
1271
|
}, z.core.$loose>>;
|
|
1655
1272
|
theme: z.ZodDefault<z.ZodUnion<readonly [z.ZodEnum<{
|
|
1656
1273
|
auto: "auto";
|
|
@@ -1703,6 +1320,7 @@ declare const widgetSettingsSchema: z.ZodObject<{
|
|
|
1703
1320
|
fullscreen: "fullscreen";
|
|
1704
1321
|
clear: "clear";
|
|
1705
1322
|
theme: "theme";
|
|
1323
|
+
popOut: "popOut";
|
|
1706
1324
|
sound: "sound";
|
|
1707
1325
|
history: "history";
|
|
1708
1326
|
language: "language";
|
|
@@ -1902,7 +1520,7 @@ type WidgetSettings = z.infer<typeof widgetSettingsSchema>;
|
|
|
1902
1520
|
declare const widgetConfigSchema: z.ZodObject<{
|
|
1903
1521
|
widgetId: z.ZodDefault<z.ZodString>;
|
|
1904
1522
|
publicKey: z.ZodOptional<z.ZodString>;
|
|
1905
|
-
aiAgentDeploymentId: z.
|
|
1523
|
+
aiAgentDeploymentId: z.ZodString;
|
|
1906
1524
|
baseUrl: z.ZodOptional<z.ZodString>;
|
|
1907
1525
|
agentApiBaseUrl: z.ZodOptional<z.ZodString>;
|
|
1908
1526
|
dataApiBaseUrl: z.ZodOptional<z.ZodString>;
|
|
@@ -1986,6 +1604,7 @@ declare const widgetConfigSchema: z.ZodObject<{
|
|
|
1986
1604
|
showSources: z.ZodDefault<z.ZodBoolean>;
|
|
1987
1605
|
disableMessageFeedback: z.ZodDefault<z.ZodBoolean>;
|
|
1988
1606
|
autoSendSuggestions: z.ZodDefault<z.ZodBoolean>;
|
|
1607
|
+
popOutUrl: z.ZodOptional<z.ZodString>;
|
|
1989
1608
|
}, z.core.$loose>>;
|
|
1990
1609
|
theme: z.ZodDefault<z.ZodUnion<readonly [z.ZodEnum<{
|
|
1991
1610
|
auto: "auto";
|
|
@@ -2038,6 +1657,7 @@ declare const widgetConfigSchema: z.ZodObject<{
|
|
|
2038
1657
|
fullscreen: "fullscreen";
|
|
2039
1658
|
clear: "clear";
|
|
2040
1659
|
theme: "theme";
|
|
1660
|
+
popOut: "popOut";
|
|
2041
1661
|
sound: "sound";
|
|
2042
1662
|
history: "history";
|
|
2043
1663
|
language: "language";
|
|
@@ -2236,7 +1856,7 @@ type WidgetConfig = z.infer<typeof widgetConfigSchema>;
|
|
|
2236
1856
|
declare const widgetConfigPartialSchema: z.ZodObject<{
|
|
2237
1857
|
widgetId: z.ZodOptional<z.ZodDefault<z.ZodString>>;
|
|
2238
1858
|
publicKey: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
2239
|
-
aiAgentDeploymentId: z.ZodOptional<z.
|
|
1859
|
+
aiAgentDeploymentId: z.ZodOptional<z.ZodString>;
|
|
2240
1860
|
baseUrl: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
2241
1861
|
agentApiBaseUrl: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
2242
1862
|
dataApiBaseUrl: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
@@ -2320,6 +1940,7 @@ declare const widgetConfigPartialSchema: z.ZodObject<{
|
|
|
2320
1940
|
showSources: z.ZodDefault<z.ZodBoolean>;
|
|
2321
1941
|
disableMessageFeedback: z.ZodDefault<z.ZodBoolean>;
|
|
2322
1942
|
autoSendSuggestions: z.ZodDefault<z.ZodBoolean>;
|
|
1943
|
+
popOutUrl: z.ZodOptional<z.ZodString>;
|
|
2323
1944
|
}, z.core.$loose>>>;
|
|
2324
1945
|
theme: z.ZodOptional<z.ZodDefault<z.ZodUnion<readonly [z.ZodEnum<{
|
|
2325
1946
|
auto: "auto";
|
|
@@ -2372,6 +1993,7 @@ declare const widgetConfigPartialSchema: z.ZodObject<{
|
|
|
2372
1993
|
fullscreen: "fullscreen";
|
|
2373
1994
|
clear: "clear";
|
|
2374
1995
|
theme: "theme";
|
|
1996
|
+
popOut: "popOut";
|
|
2375
1997
|
sound: "sound";
|
|
2376
1998
|
history: "history";
|
|
2377
1999
|
language: "language";
|
|
@@ -2614,6 +2236,7 @@ declare const widgetSettingsPartialSchema: z.ZodObject<{
|
|
|
2614
2236
|
showSources: z.ZodDefault<z.ZodBoolean>;
|
|
2615
2237
|
disableMessageFeedback: z.ZodDefault<z.ZodBoolean>;
|
|
2616
2238
|
autoSendSuggestions: z.ZodDefault<z.ZodBoolean>;
|
|
2239
|
+
popOutUrl: z.ZodOptional<z.ZodString>;
|
|
2617
2240
|
}, z.core.$loose>>>;
|
|
2618
2241
|
theme: z.ZodOptional<z.ZodDefault<z.ZodUnion<readonly [z.ZodEnum<{
|
|
2619
2242
|
auto: "auto";
|
|
@@ -2666,6 +2289,7 @@ declare const widgetSettingsPartialSchema: z.ZodObject<{
|
|
|
2666
2289
|
fullscreen: "fullscreen";
|
|
2667
2290
|
clear: "clear";
|
|
2668
2291
|
theme: "theme";
|
|
2292
|
+
popOut: "popOut";
|
|
2669
2293
|
sound: "sound";
|
|
2670
2294
|
history: "history";
|
|
2671
2295
|
language: "language";
|
|
@@ -2859,7 +2483,7 @@ type WidgetSettingsPartial = z.infer<typeof widgetSettingsPartialSchema>;
|
|
|
2859
2483
|
declare const connectionConfigPartialSchema: z.ZodObject<{
|
|
2860
2484
|
widgetId: z.ZodOptional<z.ZodDefault<z.ZodString>>;
|
|
2861
2485
|
publicKey: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
2862
|
-
aiAgentDeploymentId: z.ZodOptional<z.
|
|
2486
|
+
aiAgentDeploymentId: z.ZodOptional<z.ZodString>;
|
|
2863
2487
|
baseUrl: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
2864
2488
|
agentApiBaseUrl: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
2865
2489
|
dataApiBaseUrl: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
@@ -2966,6 +2590,7 @@ declare const serverConfigSchema: z.ZodObject<{
|
|
|
2966
2590
|
showSources: z.ZodDefault<z.ZodBoolean>;
|
|
2967
2591
|
disableMessageFeedback: z.ZodDefault<z.ZodBoolean>;
|
|
2968
2592
|
autoSendSuggestions: z.ZodDefault<z.ZodBoolean>;
|
|
2593
|
+
popOutUrl: z.ZodOptional<z.ZodString>;
|
|
2969
2594
|
}, z.core.$loose>>>;
|
|
2970
2595
|
theme: z.ZodOptional<z.ZodDefault<z.ZodUnion<readonly [z.ZodEnum<{
|
|
2971
2596
|
auto: "auto";
|
|
@@ -3018,6 +2643,7 @@ declare const serverConfigSchema: z.ZodObject<{
|
|
|
3018
2643
|
fullscreen: "fullscreen";
|
|
3019
2644
|
clear: "clear";
|
|
3020
2645
|
theme: "theme";
|
|
2646
|
+
popOut: "popOut";
|
|
3021
2647
|
sound: "sound";
|
|
3022
2648
|
history: "history";
|
|
3023
2649
|
language: "language";
|
|
@@ -3252,6 +2878,7 @@ declare const handshakeResponseSchema: z.ZodObject<{
|
|
|
3252
2878
|
showSources: z.ZodDefault<z.ZodBoolean>;
|
|
3253
2879
|
disableMessageFeedback: z.ZodDefault<z.ZodBoolean>;
|
|
3254
2880
|
autoSendSuggestions: z.ZodDefault<z.ZodBoolean>;
|
|
2881
|
+
popOutUrl: z.ZodOptional<z.ZodString>;
|
|
3255
2882
|
}, z.core.$loose>>>;
|
|
3256
2883
|
theme: z.ZodOptional<z.ZodDefault<z.ZodUnion<readonly [z.ZodEnum<{
|
|
3257
2884
|
auto: "auto";
|
|
@@ -3304,6 +2931,7 @@ declare const handshakeResponseSchema: z.ZodObject<{
|
|
|
3304
2931
|
fullscreen: "fullscreen";
|
|
3305
2932
|
clear: "clear";
|
|
3306
2933
|
theme: "theme";
|
|
2934
|
+
popOut: "popOut";
|
|
3307
2935
|
sound: "sound";
|
|
3308
2936
|
history: "history";
|
|
3309
2937
|
language: "language";
|
|
@@ -3464,20 +3092,194 @@ declare const handshakeResponseSchema: z.ZodObject<{
|
|
|
3464
3092
|
conversationId: z.ZodString;
|
|
3465
3093
|
userPrefs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
3466
3094
|
rebind: z.ZodOptional<z.ZodObject<{
|
|
3467
|
-
|
|
3468
|
-
|
|
3469
|
-
expired: "expired";
|
|
3470
|
-
invalid: "invalid";
|
|
3471
|
-
}>>;
|
|
3472
|
-
conversationId: z.ZodOptional<z.ZodEnum<{
|
|
3473
|
-
conflict: "conflict";
|
|
3474
|
-
expired: "expired";
|
|
3475
|
-
invalid: "invalid";
|
|
3476
|
-
}>>;
|
|
3477
|
-
}, z.core.$loose>>;
|
|
3095
|
+
conversationId: z.ZodString;
|
|
3096
|
+
}, z.core.$strict>>;
|
|
3478
3097
|
}, z.core.$loose>;
|
|
3479
3098
|
type HandshakeResponse = z.infer<typeof handshakeResponseSchema>;
|
|
3480
3099
|
//#endregion
|
|
3100
|
+
//#region src/stream/types.d.ts
|
|
3101
|
+
/** A 👍/👎 reaction on a rateable (assistant/operator) message; `null` clears a prior choice. */
|
|
3102
|
+
type FeedbackValue = "up" | "down" | null;
|
|
3103
|
+
//#endregion
|
|
3104
|
+
//#region src/core/events.d.ts
|
|
3105
|
+
/**
|
|
3106
|
+
* Payload shape per event. Keyed by event name; use `void` for events that
|
|
3107
|
+
* carry no data.
|
|
3108
|
+
*
|
|
3109
|
+
* **Every user-visible action fires here.** Subscribe via
|
|
3110
|
+
* `chat.on("eventName", fn)` to add analytics, side effects, or audit
|
|
3111
|
+
* trails without forking the widget. The same names also stream to the
|
|
3112
|
+
* structured logger at `info` level when `debug` is enabled.
|
|
3113
|
+
*/
|
|
3114
|
+
interface EventMap {
|
|
3115
|
+
/** Panel opened (floating / modal / drawer). */
|
|
3116
|
+
open: void;
|
|
3117
|
+
/** Panel closed. */
|
|
3118
|
+
close: void;
|
|
3119
|
+
/** Expanded mode toggled (1.5× size). Payload is the new state. */
|
|
3120
|
+
expand: boolean;
|
|
3121
|
+
/** Fullscreen mode toggled. Payload is the new state. */
|
|
3122
|
+
fullscreen: boolean;
|
|
3123
|
+
/** End-user dragged the resize grip — payload is the resolved size. */
|
|
3124
|
+
resize: {
|
|
3125
|
+
width: number;
|
|
3126
|
+
height: number;
|
|
3127
|
+
};
|
|
3128
|
+
/** A message was exchanged. Fires for user, assistant, and operator messages. */
|
|
3129
|
+
message: {
|
|
3130
|
+
role: string;
|
|
3131
|
+
text: string;
|
|
3132
|
+
};
|
|
3133
|
+
/** User submitted a message (fires before the request is sent). */
|
|
3134
|
+
send: {
|
|
3135
|
+
text: string;
|
|
3136
|
+
attachmentCount: number;
|
|
3137
|
+
};
|
|
3138
|
+
/** User cancelled an in-flight stream. */
|
|
3139
|
+
stop: void;
|
|
3140
|
+
/** Clear / new-conversation requested. */
|
|
3141
|
+
clear: void;
|
|
3142
|
+
/** User picked a chat from the history pane / sidebar. */
|
|
3143
|
+
selectConversation: {
|
|
3144
|
+
conversationId: string;
|
|
3145
|
+
};
|
|
3146
|
+
/** User clicked a suggested-message chip. */
|
|
3147
|
+
suggestion: {
|
|
3148
|
+
text: string;
|
|
3149
|
+
};
|
|
3150
|
+
/** History pane toggled. Payload is the resulting view. */
|
|
3151
|
+
toggleHistory: {
|
|
3152
|
+
view: "chat" | "history";
|
|
3153
|
+
};
|
|
3154
|
+
/** A form (intake, CSAT, …) was completed or skipped. */
|
|
3155
|
+
formSubmit: {
|
|
3156
|
+
formId: string;
|
|
3157
|
+
values: Record<string, string>;
|
|
3158
|
+
skipped: boolean;
|
|
3159
|
+
};
|
|
3160
|
+
/** User answered an ask-questions tool request (re-POST follows). */
|
|
3161
|
+
toolResult: {
|
|
3162
|
+
toolCallId: string;
|
|
3163
|
+
};
|
|
3164
|
+
/** User approved / rejected a gated tool call (re-POST follows). */
|
|
3165
|
+
toolDecision: {
|
|
3166
|
+
toolCallId: string;
|
|
3167
|
+
approved: boolean;
|
|
3168
|
+
};
|
|
3169
|
+
/**
|
|
3170
|
+
* User gave feedback on a rateable reply (AI or operator). `value` is `"up"` / `"down"`, or
|
|
3171
|
+
* `null` when they cleared a prior choice. `messageId` is the backend message
|
|
3172
|
+
* id. Also POSTed best-effort to `/pai/message-feedback`; a host listener can
|
|
3173
|
+
* mirror it to analytics.
|
|
3174
|
+
*/
|
|
3175
|
+
messageFeedback: {
|
|
3176
|
+
messageId: string;
|
|
3177
|
+
value: FeedbackValue;
|
|
3178
|
+
};
|
|
3179
|
+
/** A content list (news / help / home block) rendered. */
|
|
3180
|
+
contentView: {
|
|
3181
|
+
section: string;
|
|
3182
|
+
tags?: string;
|
|
3183
|
+
count: number;
|
|
3184
|
+
};
|
|
3185
|
+
/** An article / content item was opened. */
|
|
3186
|
+
contentOpen: {
|
|
3187
|
+
contentId: string;
|
|
3188
|
+
tags?: string;
|
|
3189
|
+
};
|
|
3190
|
+
/** The help search ran. Length + hit count only — never the query text. */
|
|
3191
|
+
contentSearch: {
|
|
3192
|
+
queryLength: number;
|
|
3193
|
+
hitCount: number;
|
|
3194
|
+
};
|
|
3195
|
+
/** An opened article was read (dwell threshold passed). Fires once per open. */
|
|
3196
|
+
contentRead: {
|
|
3197
|
+
contentId: string;
|
|
3198
|
+
};
|
|
3199
|
+
/** A link inside an opened article was followed. */
|
|
3200
|
+
contentLinkClick: {
|
|
3201
|
+
contentId: string;
|
|
3202
|
+
};
|
|
3203
|
+
/** Files attached (drag-drop, file picker, paste). */
|
|
3204
|
+
attach: {
|
|
3205
|
+
count: number;
|
|
3206
|
+
totalBytes: number;
|
|
3207
|
+
};
|
|
3208
|
+
/** An attachment was removed before send. */
|
|
3209
|
+
removeAttachment: {
|
|
3210
|
+
id: string;
|
|
3211
|
+
};
|
|
3212
|
+
/** Voice recording started. */
|
|
3213
|
+
voiceStart: void;
|
|
3214
|
+
/** Voice recording stopped and was sent for transcription. */
|
|
3215
|
+
voiceStop: {
|
|
3216
|
+
durationMs: number;
|
|
3217
|
+
};
|
|
3218
|
+
/** Voice recording cancelled (e.g. user released outside the button). */
|
|
3219
|
+
voiceCancel: void;
|
|
3220
|
+
/** End-user picked a different UI locale. Payload is the new BCP-47 tag. */
|
|
3221
|
+
localeChange: string;
|
|
3222
|
+
/** End-user picked a different theme mode (`auto` / `light` / `dark`). */
|
|
3223
|
+
themeChange: ThemePreference;
|
|
3224
|
+
/** End-user picked a different text size (`small` / `normal` / `large`). */
|
|
3225
|
+
textSizeChange: TextSize;
|
|
3226
|
+
/** End-user toggled the global sound mute. */
|
|
3227
|
+
soundToggle: {
|
|
3228
|
+
muted: boolean;
|
|
3229
|
+
};
|
|
3230
|
+
/** Page-mode sidebar collapsed / expanded. */
|
|
3231
|
+
sidebarToggle: {
|
|
3232
|
+
collapsed: boolean;
|
|
3233
|
+
};
|
|
3234
|
+
/** Pre-engagement launcher callout dismissed. */
|
|
3235
|
+
calloutDismiss: void;
|
|
3236
|
+
/** An unhandled error occurred somewhere in the transport or UI. */
|
|
3237
|
+
error: unknown;
|
|
3238
|
+
/** Connect bootstrap succeeded. Payload is the typed server response. */
|
|
3239
|
+
handshake: HandshakeResponse;
|
|
3240
|
+
/** Server replaced the requested conversationId and the widget adopted it. */
|
|
3241
|
+
conversationRebound: {
|
|
3242
|
+
previous: string;
|
|
3243
|
+
current: string;
|
|
3244
|
+
};
|
|
3245
|
+
}
|
|
3246
|
+
type EventName = keyof EventMap;
|
|
3247
|
+
//#endregion
|
|
3248
|
+
//#region src/ui/host-mode.d.ts
|
|
3249
|
+
type HostMode = "page" | "standalone" | "inline" | "modal" | "drawer" | "fullscreen" | "expanded" | "open" | "closed";
|
|
3250
|
+
//#endregion
|
|
3251
|
+
//#region src/boot.d.ts
|
|
3252
|
+
/**
|
|
3253
|
+
* Determine what `data-mode` the host should start at — matching what App's
|
|
3254
|
+
* mount-time `useEffect` will produce on its first render. Used for the initial
|
|
3255
|
+
* paint in both entry points (and `mount()`'s iframe sizing); after that, App
|
|
3256
|
+
* owns `data-mode` for the lifetime of the instance.
|
|
3257
|
+
*
|
|
3258
|
+
* `resolveInitialPanelState` is the one source of truth for "what does the first
|
|
3259
|
+
* render look like" — App.tsx uses it too. If these two paths ever pick
|
|
3260
|
+
* different initial states, an iframe physically resizes between mount and App's
|
|
3261
|
+
* first effect (the closed→open→closed flicker this pins against).
|
|
3262
|
+
*/
|
|
3263
|
+
declare function resolveInitialHostMode(options: ResolvedOptions): HostMode;
|
|
3264
|
+
//#endregion
|
|
3265
|
+
//#region src/core/hooks.d.ts
|
|
3266
|
+
/** Wildcard that matches every widget id / every event name. */
|
|
3267
|
+
declare const HOOK_WILDCARD = "*";
|
|
3268
|
+
/**
|
|
3269
|
+
* Unified lifecycle callback signature. `data` is `unknown` — narrow it
|
|
3270
|
+
* via the `event` discriminator using {@link EventMap} if needed:
|
|
3271
|
+
*
|
|
3272
|
+
* ```ts
|
|
3273
|
+
* HelpAI.hook("*", "*", (inst, event, data) => {
|
|
3274
|
+
* if (event === "message") {
|
|
3275
|
+
* const msg = data as EventMap["message"]; // { role, text }
|
|
3276
|
+
* // ...
|
|
3277
|
+
* }
|
|
3278
|
+
* });
|
|
3279
|
+
* ```
|
|
3280
|
+
*/
|
|
3281
|
+
type HookListener = (instance: ChatWidgetInstance, event: EventName, data: unknown) => void;
|
|
3282
|
+
//#endregion
|
|
3481
3283
|
//#region src/index.d.ts
|
|
3482
3284
|
/**
|
|
3483
3285
|
* Handle returned by {@link mount} / {@link init}. All methods are safe to call
|
|
@@ -3569,15 +3371,16 @@ interface ChatWidgetInstance {
|
|
|
3569
3371
|
*
|
|
3570
3372
|
* @example Single widget (default):
|
|
3571
3373
|
* ```ts
|
|
3572
|
-
* mount({ publicKey, presentation: { mode: 'inline' }, target: document.getElementById('chat') });
|
|
3374
|
+
* mount({ publicKey, aiAgentDeploymentId, presentation: { mode: 'inline' }, target: document.getElementById('chat') });
|
|
3573
3375
|
* ```
|
|
3574
3376
|
* @example Two widgets on one page:
|
|
3575
3377
|
* ```ts
|
|
3576
|
-
* mount({ widgetId: 'support', publicKey: KEY_A, target: supportEl });
|
|
3577
|
-
* mount({ widgetId: 'sales',
|
|
3378
|
+
* mount({ widgetId: 'support', publicKey: KEY_A, aiAgentDeploymentId: DEPLOYMENT_A, target: supportEl });
|
|
3379
|
+
* mount({ widgetId: 'sales', publicKey: KEY_B, aiAgentDeploymentId: DEPLOYMENT_B, target: salesEl });
|
|
3578
3380
|
* ```
|
|
3579
3381
|
*/
|
|
3580
3382
|
declare function mount(opts: ChatWidgetOptions & {
|
|
3383
|
+
aiAgentDeploymentId: string;
|
|
3581
3384
|
target?: HTMLElement;
|
|
3582
3385
|
}): ChatWidgetInstance;
|
|
3583
3386
|
/**
|
|
@@ -3586,6 +3389,7 @@ declare function mount(opts: ChatWidgetOptions & {
|
|
|
3586
3389
|
* behaves like {@link mount}. Safe to call on every route change in an SPA.
|
|
3587
3390
|
*/
|
|
3588
3391
|
declare function init(opts: ChatWidgetOptions & {
|
|
3392
|
+
aiAgentDeploymentId: string;
|
|
3589
3393
|
target?: HTMLElement;
|
|
3590
3394
|
}): ChatWidgetInstance;
|
|
3591
3395
|
/**
|