@helpai/elements 0.72.0 → 0.73.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 +17 -16
- package/configurator.mjs +1 -1
- package/elements-web-component.esm.js +30 -30
- package/elements-web-component.esm.js.map +4 -4
- package/elements.cjs.js +29 -29
- package/elements.cjs.js.map +4 -4
- package/elements.esm.js +29 -29
- package/elements.esm.js.map +4 -4
- package/elements.js +29 -29
- package/elements.js.map +4 -4
- package/index.d.ts +181 -208
- package/index.mjs +5 -5
- package/package.json +1 -1
- package/schema.d.ts +34 -65
- package/schema.json +7 -81
- package/schema.mjs +1 -1
- package/style.css +1 -1
- package/web-component.d.ts +5 -5
- package/web-component.mjs +6 -6
package/index.d.ts
CHANGED
|
@@ -32,8 +32,8 @@ interface ClientStorage {
|
|
|
32
32
|
*
|
|
33
33
|
* The widget bundles five complete locales (en/fr/ar/es/he — English is also the
|
|
34
34
|
* fallback for any missing key; see {@link BUILTIN_STRINGS}). Further locales, or
|
|
35
|
-
* per-key overrides, are supplied by the page owner (`init({ strings })`)
|
|
36
|
-
* SaaS backend in
|
|
35
|
+
* per-key overrides, are supplied by the page owner (`init({ i18n: { strings } })`)
|
|
36
|
+
* or the SaaS backend in `config.i18n.strings` — both pushed *partially*: only the keys
|
|
37
37
|
* they want to override.
|
|
38
38
|
*
|
|
39
39
|
* To keep render hot-paths cheap, the merged shape is **pre-computed once**
|
|
@@ -50,8 +50,8 @@ type LocaleStrings = Partial<Record<StringKey, string>>;
|
|
|
50
50
|
*/
|
|
51
51
|
type Strings = Record<StringKey, string>;
|
|
52
52
|
/**
|
|
53
|
-
* Override shape accepted by both `init({ strings })` and the server's
|
|
54
|
-
* `
|
|
53
|
+
* Override shape accepted by both `init({ i18n: { strings } })` and the server's
|
|
54
|
+
* `config.i18n.strings`. Two forms supported:
|
|
55
55
|
*
|
|
56
56
|
* 1. **Flat** — `{ send: "Click", stop: "Halt" }`. Applies to the active
|
|
57
57
|
* locale. Convenient for single-language deployments.
|
|
@@ -66,161 +66,6 @@ type Strings = Record<StringKey, string>;
|
|
|
66
66
|
*/
|
|
67
67
|
type StringsOverride = LocaleStrings | Partial<Record<string, LocaleStrings>>;
|
|
68
68
|
//#endregion
|
|
69
|
-
//#region src/core/persistence.d.ts
|
|
70
|
-
/** Drag-resized panel dimensions. Persisted only when resize is enabled. */
|
|
71
|
-
interface WidgetSize {
|
|
72
|
-
width: number;
|
|
73
|
-
height: number;
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* User-changeable preferences. Sent to the backend on every request as a
|
|
77
|
-
* `userPrefs` field so the server can detect drift (e.g. user changed
|
|
78
|
-
* locale on another tab) and reconcile.
|
|
79
|
-
*
|
|
80
|
-
* Every field is optional — an unset key inherits the server / page-owner
|
|
81
|
-
* default. Empty object `{}` means "no preference recorded yet."
|
|
82
|
-
*/
|
|
83
|
-
interface UserPrefs {
|
|
84
|
-
/** BCP-47 tag picked from the language switcher. */
|
|
85
|
-
locale?: string;
|
|
86
|
-
/** Drag-resized panel dimensions. */
|
|
87
|
-
widgetSize?: WidgetSize;
|
|
88
|
-
/** Sound on/off toggle (icon button). */
|
|
89
|
-
soundMuted?: boolean;
|
|
90
|
-
/** Theme picked from the theme switcher. */
|
|
91
|
-
themeMode?: "auto" | "light" | "dark";
|
|
92
|
-
/** Text size picked from the text-size switcher. */
|
|
93
|
-
textSize?: "small" | "normal" | "large";
|
|
94
|
-
}
|
|
95
|
-
//#endregion
|
|
96
|
-
//#region src/stream/types.d.ts
|
|
97
|
-
/** A 👍/👎 reaction on a rateable (assistant/operator) message; `null` clears a prior choice. */
|
|
98
|
-
type FeedbackValue = "up" | "down" | null;
|
|
99
|
-
//#endregion
|
|
100
|
-
//#region src/stream/protocol.d.ts
|
|
101
|
-
/** A tool reference on the wire: `{ code, config }`. `config` is opaque. */
|
|
102
|
-
interface ToolRef {
|
|
103
|
-
code: string;
|
|
104
|
-
config?: Record<string, unknown>;
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Who is driving replies in a conversation — the widget mirrors the backend `controlMode`.
|
|
108
|
-
* - `ai-agent`: the AI agent answers (normal operation).
|
|
109
|
-
* - `awaiting_operator`: operator-control requested, the AI no longer answers — the turn routes to the
|
|
110
|
-
* operator — while waiting in the operator queue.
|
|
111
|
-
* - `operator`: a workspace operator took over and is replying.
|
|
112
|
-
*
|
|
113
|
-
* Carried on `HandshakeResponse.controlState`, `LoadConversationResponse.controlState` (resume +
|
|
114
|
-
* history-switch), and the `data-control-state` stream part (on the reply stream). Absent / unknown →
|
|
115
|
-
* treated as `"ai-agent"`.
|
|
116
|
-
*/
|
|
117
|
-
type ControlMode = "ai-agent" | "awaiting_operator" | "operator";
|
|
118
|
-
/**
|
|
119
|
-
* The control-state snapshot the widget reads to render composer/typing/banner state. The optional
|
|
120
|
-
* `operatorAvailable` (set on the operator-request response + the awaiting terminal part) tells the
|
|
121
|
-
* widget whether to show "connecting…" or the async-capture ("leave your details") copy.
|
|
122
|
-
*/
|
|
123
|
-
interface ControlState {
|
|
124
|
-
controlMode: ControlMode;
|
|
125
|
-
/**
|
|
126
|
-
* The operator's 2-letter initials (operator mode only) — shown in the bubble chrome + banner. The
|
|
127
|
-
* visitor never sees the full name (privacy); the backend derives the initials. `assignedOperatorId`
|
|
128
|
-
* also rides the wire but the widget doesn't render it, so it isn't modeled here.
|
|
129
|
-
*/
|
|
130
|
-
assignedOperatorInitials?: string;
|
|
131
|
-
/** Whether anyone was in the operator pool when operator-control was requested (awaiting mode advisory). */
|
|
132
|
-
operatorAvailable?: boolean;
|
|
133
|
-
}
|
|
134
|
-
/** One-shot bot persona shown in the panel header. */
|
|
135
|
-
interface ConversationAgent {
|
|
136
|
-
name: string;
|
|
137
|
-
/** Image URL or data URI. When omitted, initials render from `name`. */
|
|
138
|
-
avatar?: string;
|
|
139
|
-
/** Subtitle ("AI Assistant", "Support team", …). */
|
|
140
|
-
title?: string;
|
|
141
|
-
/** Presence indicator. Default: `'online'`. */
|
|
142
|
-
status?: "online" | "away" | "offline";
|
|
143
|
-
}
|
|
144
|
-
/** A clickable quick-reply chip. */
|
|
145
|
-
interface ConversationSuggestion {
|
|
146
|
-
id: string;
|
|
147
|
-
/** What the chip displays. */
|
|
148
|
-
label: string;
|
|
149
|
-
/** What actually gets sent when clicked. Defaults to `label`. */
|
|
150
|
-
text?: string;
|
|
151
|
-
}
|
|
152
|
-
/** Welcome payload pushed into the message list on first open. */
|
|
153
|
-
interface ConversationWelcome {
|
|
154
|
-
messages?: Array<{
|
|
155
|
-
id: string;
|
|
156
|
-
role: "assistant" | "system";
|
|
157
|
-
text: string;
|
|
158
|
-
}>;
|
|
159
|
-
suggestions?: ConversationSuggestion[];
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* Response from `POST /pai/handshake` — the widget's one mount-time
|
|
163
|
-
* round-trip. Deliberately LIGHT: identity + deployment surface only
|
|
164
|
-
* (config, agent persona, welcome, page-mode site/blocks, userPrefs).
|
|
165
|
-
* The conversation THREAD is a separate, lazily-fetched read
|
|
166
|
-
* (`GET /conversation`) that only runs once the widget is activated
|
|
167
|
-
* (opened) — a closed launcher costs the page exactly one request.
|
|
168
|
-
*
|
|
169
|
-
* The `userPrefs` field (when present) is the server's authoritative
|
|
170
|
-
* copy of per-visitor preferences — the client should adopt it and update
|
|
171
|
-
* its local cache. Lets a user picking French on their phone see the
|
|
172
|
-
* widget in French when they open it on their laptop (assuming the same
|
|
173
|
-
* `visitorId`, e.g. via authenticated conversation — out of scope for v1).
|
|
174
|
-
*/
|
|
175
|
-
interface HandshakeResponse$1 {
|
|
176
|
-
/**
|
|
177
|
-
* Public runtime conversation id. The widget mints this UUIDv7 and the backend
|
|
178
|
-
* validates that it belongs to the public deployment + visitor.
|
|
179
|
-
*/
|
|
180
|
-
conversationId: string;
|
|
181
|
-
visitorId?: string;
|
|
182
|
-
/** Bot persona in the panel header (name, avatar, status). */
|
|
183
|
-
agent?: ConversationAgent;
|
|
184
|
-
/** Initial assistant messages + quick-reply chips. */
|
|
185
|
-
welcome?: ConversationWelcome;
|
|
186
|
-
/**
|
|
187
|
-
* Deployment-wide widget configuration the dashboard admin saved
|
|
188
|
-
* (mode / theme / launcher / actions / composer / features / …).
|
|
189
|
-
* Client adopts as defaults; customer's `init({...})` still wins
|
|
190
|
-
* per-field. Same for every visitor of this deployment.
|
|
191
|
-
*/
|
|
192
|
-
config?: ServerConfig$1;
|
|
193
|
-
/** Page-mode site config (logo, title). Backend ships it whenever the deployment renders the page-shell sidebar. */
|
|
194
|
-
site?: Record<string, unknown>;
|
|
195
|
-
/** Page-mode sidebar blocks (navigation, link cards). Backend ships it whenever the deployment renders the page-shell sidebar. */
|
|
196
|
-
blocks?: Record<string, unknown>;
|
|
197
|
-
/** Current control state — seeds the composer/typing/banner state on connect. Absent → `ai-agent`. */
|
|
198
|
-
controlState?: ControlState;
|
|
199
|
-
/**
|
|
200
|
-
* Server's authoritative copy of the visitor's preferences. When present,
|
|
201
|
-
* client adopts it (overrides local cache) and re-applies it to the UI
|
|
202
|
-
* (locale, panel size, sound mute). Absent → client keeps its cache.
|
|
203
|
-
*/
|
|
204
|
-
userPrefs?: UserPrefs;
|
|
205
|
-
/**
|
|
206
|
-
* Optional rebind metadata. When the server returns a `visitorId` /
|
|
207
|
-
* `conversationId` different from what the client sent, this block tells
|
|
208
|
-
* the client WHY — useful for telemetry and the `visitorRebound` /
|
|
209
|
-
* `conversationRebound` events fired into the host page. Server is free to
|
|
210
|
-
* omit it: the client detects rebinding by comparing request vs
|
|
211
|
-
* response ids regardless.
|
|
212
|
-
*
|
|
213
|
-
* Common reasons: `"conflict"` (the id collided with an existing
|
|
214
|
-
* record), `"expired"` (the id is too old to be re-used), `"invalid"`
|
|
215
|
-
* (malformed / not a UUIDv7). Custom strings are passed through to
|
|
216
|
-
* listeners verbatim.
|
|
217
|
-
*/
|
|
218
|
-
rebind?: {
|
|
219
|
-
visitorId?: string;
|
|
220
|
-
conversationId?: string;
|
|
221
|
-
};
|
|
222
|
-
}
|
|
223
|
-
//#endregion
|
|
224
69
|
//#region src/core/config/types/common.d.ts
|
|
225
70
|
/**
|
|
226
71
|
* Primitive type aliases shared across every config section. Kept in
|
|
@@ -290,6 +135,11 @@ type ActionName = "clear" | "expand" | "fullscreen" | "sound" | "history" | "lan
|
|
|
290
135
|
type ActionList = ActionName[];
|
|
291
136
|
//#endregion
|
|
292
137
|
//#region src/core/config/types/composer.d.ts
|
|
138
|
+
/**
|
|
139
|
+
* Composer chrome and capability flags. `ChatWidgetOptions.composer` owns the
|
|
140
|
+
* send-button skin + attachment limits; `ChatWidgetOptions.features` owns voice,
|
|
141
|
+
* file-upload, HITL, and operator gates.
|
|
142
|
+
*/
|
|
293
143
|
/**
|
|
294
144
|
* How voice input is captured and transcribed.
|
|
295
145
|
*
|
|
@@ -304,12 +154,6 @@ type VoiceMode = "local" | "server" | "disabled";
|
|
|
304
154
|
interface FeatureFlags {
|
|
305
155
|
/** Voice input behaviour (see {@link VoiceMode}). Default: `'local'`. */
|
|
306
156
|
voice?: VoiceMode;
|
|
307
|
-
/**
|
|
308
|
-
* Backend tools the assistant may invoke. Accepts either a bare tool code
|
|
309
|
-
* (`"tool:send-money"`) or a rich ref (`{ code, config }`) — the wire
|
|
310
|
-
* format always uses the rich shape.
|
|
311
|
-
*/
|
|
312
|
-
tools?: Array<string | ToolRef>;
|
|
313
157
|
/**
|
|
314
158
|
* Turn OFF the human-in-the-loop tool UI — the inline ask-questions form and the
|
|
315
159
|
* approve/reject controls for gated tools. Unset/`false` = shown (default); `true`
|
|
@@ -337,7 +181,6 @@ interface ResolvedFeatures {
|
|
|
337
181
|
voice: VoiceMode;
|
|
338
182
|
humanInLoop: boolean;
|
|
339
183
|
operatorRequest: boolean;
|
|
340
|
-
tools?: Array<string | ToolRef>;
|
|
341
184
|
}
|
|
342
185
|
/**
|
|
343
186
|
* Client-side attachment limits. Server enforcement is still required —
|
|
@@ -371,7 +214,7 @@ interface ComposerOptions {
|
|
|
371
214
|
//#endregion
|
|
372
215
|
//#region src/core/config/types/feedback.d.ts
|
|
373
216
|
/**
|
|
374
|
-
* Audible + tactile feedback knobs. Both default to enabled (browser
|
|
217
|
+
* Audible + tactile feedback knobs. Both channels default to enabled (browser
|
|
375
218
|
* autoplay policy still gates audio playback).
|
|
376
219
|
*/
|
|
377
220
|
/** Lifecycle events the feedback bus can react to. */
|
|
@@ -385,7 +228,7 @@ type FeedbackEvent = "messageReceived" | "messageSent" | "error" | "voiceStart"
|
|
|
385
228
|
*/
|
|
386
229
|
type SoundEventValue = boolean | string;
|
|
387
230
|
interface SoundOptions {
|
|
388
|
-
/** Master on/off. Default: `
|
|
231
|
+
/** Master on/off. Default: `true` (browser autoplay policy still applies). */
|
|
389
232
|
enabled?: boolean;
|
|
390
233
|
/** Global volume 0..1. Default: `0.3` (subtle). */
|
|
391
234
|
volume?: number;
|
|
@@ -410,7 +253,7 @@ interface HapticsOptions {
|
|
|
410
253
|
events?: Partial<Record<FeedbackEvent, HapticEventValue>>;
|
|
411
254
|
}
|
|
412
255
|
/**
|
|
413
|
-
* Section: audible + tactile feedback. Both default to enabled
|
|
256
|
+
* Section: audible + tactile feedback. Both channels default to enabled
|
|
414
257
|
* (browser autoplay policy still gates audio playback).
|
|
415
258
|
*/
|
|
416
259
|
interface FeedbackOptions {
|
|
@@ -1061,7 +904,8 @@ interface ResolvedTracking {
|
|
|
1061
904
|
* Issued by the SaaS portal, pasted into their site code.
|
|
1062
905
|
* - **Widget settings (L3)** — nested sections owned by the portal
|
|
1063
906
|
* admin: `presentation`, `behavior`, `theme`, `launcher`, `header`,
|
|
1064
|
-
* `composer`, `
|
|
907
|
+
* `composer`, `feedback`, `i18n`, `footer`, `features`, and the other
|
|
908
|
+
* schema-backed sections below.
|
|
1065
909
|
*
|
|
1066
910
|
* Runtime-only fields (`target`, `storage`, `onMessage` callbacks) live
|
|
1067
911
|
* alongside at the top level — they're function / DOM types that can't be
|
|
@@ -1129,7 +973,7 @@ interface ChatWidgetOptions {
|
|
|
1129
973
|
feedback?: FeedbackOptions;
|
|
1130
974
|
i18n?: I18nOptions;
|
|
1131
975
|
footer?: FooterOptions;
|
|
1132
|
-
/** Capability flags (file upload, voice mode,
|
|
976
|
+
/** Capability flags (file upload, voice mode, HITL, operator request). Server-pushable. */
|
|
1133
977
|
features?: FeatureFlags;
|
|
1134
978
|
/** Event-driven forms (signal capture, CSAT, intake, consent…). Server-pushable. */
|
|
1135
979
|
forms?: FormsOptions;
|
|
@@ -1256,7 +1100,7 @@ interface ResolvedOptions {
|
|
|
1256
1100
|
onError?: ChatWidgetOptions["onError"];
|
|
1257
1101
|
}
|
|
1258
1102
|
/**
|
|
1259
|
-
* Shape of the server-pushed `
|
|
1103
|
+
* Shape of the server-pushed `config` object in `HandshakeResponse`.
|
|
1260
1104
|
*
|
|
1261
1105
|
* Matches a subset of {@link ChatWidgetOptions} — anything the server can
|
|
1262
1106
|
* reasonably dictate (UI, behaviour, routing). Callbacks (`onMessage` etc.)
|
|
@@ -1326,6 +1170,158 @@ interface LogEntry {
|
|
|
1326
1170
|
payload?: unknown;
|
|
1327
1171
|
}
|
|
1328
1172
|
//#endregion
|
|
1173
|
+
//#region src/core/persistence.d.ts
|
|
1174
|
+
/** Drag-resized panel dimensions. Persisted only when resize is enabled. */
|
|
1175
|
+
interface WidgetSize {
|
|
1176
|
+
width: number;
|
|
1177
|
+
height: number;
|
|
1178
|
+
}
|
|
1179
|
+
/**
|
|
1180
|
+
* User-changeable preferences. Sent to the backend on every request as a
|
|
1181
|
+
* `userPrefs` field so the server can detect drift (e.g. user changed
|
|
1182
|
+
* locale on another tab) and reconcile.
|
|
1183
|
+
*
|
|
1184
|
+
* Every field is optional — an unset key inherits the server / page-owner
|
|
1185
|
+
* default. Empty object `{}` means "no preference recorded yet."
|
|
1186
|
+
*/
|
|
1187
|
+
interface UserPrefs {
|
|
1188
|
+
/** BCP-47 tag picked from the language switcher. */
|
|
1189
|
+
locale?: string;
|
|
1190
|
+
/** Drag-resized panel dimensions. */
|
|
1191
|
+
widgetSize?: WidgetSize;
|
|
1192
|
+
/** Sound on/off toggle (icon button). */
|
|
1193
|
+
soundMuted?: boolean;
|
|
1194
|
+
/** Theme picked from the theme switcher. */
|
|
1195
|
+
themeMode?: "auto" | "light" | "dark";
|
|
1196
|
+
/** Text size picked from the text-size switcher. */
|
|
1197
|
+
textSize?: "small" | "normal" | "large";
|
|
1198
|
+
}
|
|
1199
|
+
//#endregion
|
|
1200
|
+
//#region src/stream/types.d.ts
|
|
1201
|
+
/** A 👍/👎 reaction on a rateable (assistant/operator) message; `null` clears a prior choice. */
|
|
1202
|
+
type FeedbackValue = "up" | "down" | null;
|
|
1203
|
+
//#endregion
|
|
1204
|
+
//#region src/stream/protocol.d.ts
|
|
1205
|
+
/**
|
|
1206
|
+
* Who is driving replies in a conversation — the widget mirrors the backend `controlMode`.
|
|
1207
|
+
* - `ai-agent`: the AI agent answers (normal operation).
|
|
1208
|
+
* - `awaiting_operator`: operator-control requested, the AI no longer answers — the turn routes to the
|
|
1209
|
+
* operator — while waiting in the operator queue.
|
|
1210
|
+
* - `operator`: a workspace operator took over and is replying.
|
|
1211
|
+
*
|
|
1212
|
+
* Carried on `HandshakeResponse.controlState`, `LoadConversationResponse.controlState` (resume +
|
|
1213
|
+
* history-switch), and the `data-control-state` stream part (on the reply stream). Absent / unknown →
|
|
1214
|
+
* treated as `"ai-agent"`.
|
|
1215
|
+
*/
|
|
1216
|
+
type ControlMode = "ai-agent" | "awaiting_operator" | "operator";
|
|
1217
|
+
/**
|
|
1218
|
+
* The control-state snapshot the widget reads to render composer/typing/banner state. The optional
|
|
1219
|
+
* `operatorAvailable` (set on the operator-request response + the awaiting terminal part) tells the
|
|
1220
|
+
* widget whether to show "connecting…" or the async-capture ("leave your details") copy.
|
|
1221
|
+
*/
|
|
1222
|
+
interface ControlState {
|
|
1223
|
+
controlMode: ControlMode;
|
|
1224
|
+
/** Monotonic state version: orders received snapshots and fences request/cancel retries to their observed cycle. */
|
|
1225
|
+
controlRevision?: number;
|
|
1226
|
+
/**
|
|
1227
|
+
* The operator's 2-letter initials (operator mode only) — shown in the bubble chrome + banner. The
|
|
1228
|
+
* visitor never sees the full name (privacy); the backend derives the initials. `assignedOperatorId`
|
|
1229
|
+
* also rides the wire but the widget doesn't render it, so it isn't modeled here.
|
|
1230
|
+
*/
|
|
1231
|
+
assignedOperatorInitials?: string;
|
|
1232
|
+
/** Whether anyone was in the operator pool when operator-control was requested (awaiting mode advisory). */
|
|
1233
|
+
operatorAvailable?: boolean;
|
|
1234
|
+
}
|
|
1235
|
+
/** One-shot bot persona shown in the panel header. */
|
|
1236
|
+
interface ConversationAgent {
|
|
1237
|
+
name: string;
|
|
1238
|
+
/** Image URL or data URI. When omitted, initials render from `name`. */
|
|
1239
|
+
avatar?: string;
|
|
1240
|
+
/** Subtitle ("AI Assistant", "Support team", …). */
|
|
1241
|
+
title?: string;
|
|
1242
|
+
/** Presence indicator. Default: `'online'`. */
|
|
1243
|
+
status?: "online" | "away" | "offline";
|
|
1244
|
+
}
|
|
1245
|
+
/** A clickable quick-reply chip. */
|
|
1246
|
+
interface ConversationSuggestion {
|
|
1247
|
+
id: string;
|
|
1248
|
+
/** What the chip displays. */
|
|
1249
|
+
label: string;
|
|
1250
|
+
/** What actually gets sent when clicked. Defaults to `label`. */
|
|
1251
|
+
text?: string;
|
|
1252
|
+
}
|
|
1253
|
+
/** Welcome payload pushed into the message list on first open. */
|
|
1254
|
+
interface ConversationWelcome {
|
|
1255
|
+
messages?: Array<{
|
|
1256
|
+
id: string;
|
|
1257
|
+
role: "assistant" | "system";
|
|
1258
|
+
text: string;
|
|
1259
|
+
}>;
|
|
1260
|
+
suggestions?: ConversationSuggestion[];
|
|
1261
|
+
}
|
|
1262
|
+
/**
|
|
1263
|
+
* Response from `POST /pai/handshake` — the widget's one mount-time
|
|
1264
|
+
* round-trip. Deliberately LIGHT: identity + deployment surface only
|
|
1265
|
+
* (config, agent persona, welcome, page-mode site/blocks, userPrefs).
|
|
1266
|
+
* The conversation THREAD is a separate, lazily-fetched read
|
|
1267
|
+
* (`GET /conversation`) that only runs once the widget is activated
|
|
1268
|
+
* (opened) — a closed launcher costs the page exactly one request.
|
|
1269
|
+
*
|
|
1270
|
+
* The `userPrefs` field (when present) is the server's authoritative
|
|
1271
|
+
* copy of per-visitor preferences — the client should adopt it and update
|
|
1272
|
+
* its local cache. Lets a user picking French on their phone see the
|
|
1273
|
+
* widget in French when they open it on their laptop (assuming the same
|
|
1274
|
+
* `visitorId`, e.g. via authenticated conversation — out of scope for v1).
|
|
1275
|
+
*/
|
|
1276
|
+
interface HandshakeResponse$1 {
|
|
1277
|
+
/**
|
|
1278
|
+
* Public runtime conversation id. The widget mints this UUIDv7 and the backend
|
|
1279
|
+
* validates that it belongs to the public deployment + visitor.
|
|
1280
|
+
*/
|
|
1281
|
+
conversationId: string;
|
|
1282
|
+
visitorId?: string;
|
|
1283
|
+
/** Bot persona in the panel header (name, avatar, status). */
|
|
1284
|
+
agent?: ConversationAgent;
|
|
1285
|
+
/** Initial assistant messages + quick-reply chips. */
|
|
1286
|
+
welcome?: ConversationWelcome;
|
|
1287
|
+
/**
|
|
1288
|
+
* Deployment-wide widget configuration the dashboard admin saved
|
|
1289
|
+
* (mode / theme / launcher / actions / composer / features / …).
|
|
1290
|
+
* Client adopts as defaults; customer's `init({...})` still wins
|
|
1291
|
+
* per-field. Same for every visitor of this deployment.
|
|
1292
|
+
*/
|
|
1293
|
+
config?: ServerConfig$1;
|
|
1294
|
+
/** Page-mode site config (logo, title). Backend ships it whenever the deployment renders the page-shell sidebar. */
|
|
1295
|
+
site?: Record<string, unknown>;
|
|
1296
|
+
/** Page-mode sidebar blocks (navigation, link cards). Backend ships it whenever the deployment renders the page-shell sidebar. */
|
|
1297
|
+
blocks?: Record<string, unknown>;
|
|
1298
|
+
/** Current control state — seeds the composer/typing/banner state on connect. Absent → `ai-agent`. */
|
|
1299
|
+
controlState?: ControlState;
|
|
1300
|
+
/**
|
|
1301
|
+
* Server's authoritative copy of the visitor's preferences. When present,
|
|
1302
|
+
* client adopts it (overrides local cache) and re-applies it to the UI
|
|
1303
|
+
* (locale, panel size, sound mute). Absent → client keeps its cache.
|
|
1304
|
+
*/
|
|
1305
|
+
userPrefs?: UserPrefs;
|
|
1306
|
+
/**
|
|
1307
|
+
* Optional rebind metadata. When the server returns a `visitorId` /
|
|
1308
|
+
* `conversationId` different from what the client sent, this block tells
|
|
1309
|
+
* the client WHY — useful for telemetry and the `visitorRebound` /
|
|
1310
|
+
* `conversationRebound` events fired into the host page. Server is free to
|
|
1311
|
+
* omit it: the client detects rebinding by comparing request vs
|
|
1312
|
+
* response ids regardless.
|
|
1313
|
+
*
|
|
1314
|
+
* Common reasons: `"conflict"` (the id collided with an existing
|
|
1315
|
+
* record), `"expired"` (the id is too old to be re-used), `"invalid"`
|
|
1316
|
+
* (malformed / not a UUIDv7). Custom strings are passed through to
|
|
1317
|
+
* listeners verbatim.
|
|
1318
|
+
*/
|
|
1319
|
+
rebind?: {
|
|
1320
|
+
visitorId?: string;
|
|
1321
|
+
conversationId?: string;
|
|
1322
|
+
};
|
|
1323
|
+
}
|
|
1324
|
+
//#endregion
|
|
1329
1325
|
//#region src/core/events.d.ts
|
|
1330
1326
|
/**
|
|
1331
1327
|
* Payload shape per event. Keyed by event name; use `void` for events that
|
|
@@ -1779,10 +1775,6 @@ declare const widgetSettingsSchema: z.ZodObject<{
|
|
|
1779
1775
|
server: "server";
|
|
1780
1776
|
disabled: "disabled";
|
|
1781
1777
|
}>>;
|
|
1782
|
-
tools: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
1783
|
-
code: z.ZodString;
|
|
1784
|
-
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
1785
|
-
}, z.core.$loose>]>>>;
|
|
1786
1778
|
disableHumanInLoop: z.ZodDefault<z.ZodBoolean>;
|
|
1787
1779
|
enableOperatorRequest: z.ZodDefault<z.ZodBoolean>;
|
|
1788
1780
|
}, z.core.$loose>>;
|
|
@@ -1800,9 +1792,9 @@ declare const widgetSettingsSchema: z.ZodObject<{
|
|
|
1800
1792
|
label: z.ZodString;
|
|
1801
1793
|
type: z.ZodEnum<{
|
|
1802
1794
|
number: "number";
|
|
1795
|
+
url: "url";
|
|
1803
1796
|
date: "date";
|
|
1804
1797
|
text: "text";
|
|
1805
|
-
url: "url";
|
|
1806
1798
|
email: "email";
|
|
1807
1799
|
tel: "tel";
|
|
1808
1800
|
time: "time";
|
|
@@ -1899,10 +1891,10 @@ declare const widgetSettingsSchema: z.ZodObject<{
|
|
|
1899
1891
|
}, z.core.$loose>;
|
|
1900
1892
|
type WidgetSettings = z.infer<typeof widgetSettingsSchema>;
|
|
1901
1893
|
/**
|
|
1902
|
-
* Full
|
|
1903
|
-
* extras. The dashboard / dev configurator typically only
|
|
1904
|
-
*
|
|
1905
|
-
* surface, `connectionConfigSchema` for
|
|
1894
|
+
* Full tooling schema — connection + widget settings + page-mode
|
|
1895
|
+
* handshake extras. The dashboard / dev configurator typically only
|
|
1896
|
+
* edits one part at a time (`widgetSettingsSchema` for the dashboard
|
|
1897
|
+
* surface, `connectionConfigSchema` for developer-facing fields).
|
|
1906
1898
|
*/
|
|
1907
1899
|
declare const widgetConfigSchema: z.ZodObject<{
|
|
1908
1900
|
widgetId: z.ZodDefault<z.ZodString>;
|
|
@@ -2118,10 +2110,6 @@ declare const widgetConfigSchema: z.ZodObject<{
|
|
|
2118
2110
|
server: "server";
|
|
2119
2111
|
disabled: "disabled";
|
|
2120
2112
|
}>>;
|
|
2121
|
-
tools: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
2122
|
-
code: z.ZodString;
|
|
2123
|
-
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
2124
|
-
}, z.core.$loose>]>>>;
|
|
2125
2113
|
disableHumanInLoop: z.ZodDefault<z.ZodBoolean>;
|
|
2126
2114
|
enableOperatorRequest: z.ZodDefault<z.ZodBoolean>;
|
|
2127
2115
|
}, z.core.$loose>>;
|
|
@@ -2139,9 +2127,9 @@ declare const widgetConfigSchema: z.ZodObject<{
|
|
|
2139
2127
|
label: z.ZodString;
|
|
2140
2128
|
type: z.ZodEnum<{
|
|
2141
2129
|
number: "number";
|
|
2130
|
+
url: "url";
|
|
2142
2131
|
date: "date";
|
|
2143
2132
|
text: "text";
|
|
2144
|
-
url: "url";
|
|
2145
2133
|
email: "email";
|
|
2146
2134
|
tel: "tel";
|
|
2147
2135
|
time: "time";
|
|
@@ -2456,10 +2444,6 @@ declare const widgetConfigPartialSchema: z.ZodObject<{
|
|
|
2456
2444
|
server: "server";
|
|
2457
2445
|
disabled: "disabled";
|
|
2458
2446
|
}>>;
|
|
2459
|
-
tools: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
2460
|
-
code: z.ZodString;
|
|
2461
|
-
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
2462
|
-
}, z.core.$loose>]>>>;
|
|
2463
2447
|
disableHumanInLoop: z.ZodDefault<z.ZodBoolean>;
|
|
2464
2448
|
enableOperatorRequest: z.ZodDefault<z.ZodBoolean>;
|
|
2465
2449
|
}, z.core.$loose>>>;
|
|
@@ -2477,9 +2461,9 @@ declare const widgetConfigPartialSchema: z.ZodObject<{
|
|
|
2477
2461
|
label: z.ZodString;
|
|
2478
2462
|
type: z.ZodEnum<{
|
|
2479
2463
|
number: "number";
|
|
2464
|
+
url: "url";
|
|
2480
2465
|
date: "date";
|
|
2481
2466
|
text: "text";
|
|
2482
|
-
url: "url";
|
|
2483
2467
|
email: "email";
|
|
2484
2468
|
tel: "tel";
|
|
2485
2469
|
time: "time";
|
|
@@ -2754,10 +2738,6 @@ declare const widgetSettingsPartialSchema: z.ZodObject<{
|
|
|
2754
2738
|
server: "server";
|
|
2755
2739
|
disabled: "disabled";
|
|
2756
2740
|
}>>;
|
|
2757
|
-
tools: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
2758
|
-
code: z.ZodString;
|
|
2759
|
-
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
2760
|
-
}, z.core.$loose>]>>>;
|
|
2761
2741
|
disableHumanInLoop: z.ZodDefault<z.ZodBoolean>;
|
|
2762
2742
|
enableOperatorRequest: z.ZodDefault<z.ZodBoolean>;
|
|
2763
2743
|
}, z.core.$loose>>>;
|
|
@@ -2775,9 +2755,9 @@ declare const widgetSettingsPartialSchema: z.ZodObject<{
|
|
|
2775
2755
|
label: z.ZodString;
|
|
2776
2756
|
type: z.ZodEnum<{
|
|
2777
2757
|
number: "number";
|
|
2758
|
+
url: "url";
|
|
2778
2759
|
date: "date";
|
|
2779
2760
|
text: "text";
|
|
2780
|
-
url: "url";
|
|
2781
2761
|
email: "email";
|
|
2782
2762
|
tel: "tel";
|
|
2783
2763
|
time: "time";
|
|
@@ -2914,9 +2894,10 @@ type ConnectionConfigPartial = z.infer<typeof connectionConfigPartialSchema>;
|
|
|
2914
2894
|
/**
|
|
2915
2895
|
* Server-pushable widget settings. Same surface as the editable
|
|
2916
2896
|
* {@link widgetSettingsSchema} but every field is optional (the server
|
|
2917
|
-
* pushes patches, not full configs).
|
|
2918
|
-
*
|
|
2919
|
-
*
|
|
2897
|
+
* pushes patches, not full configs). Embed identity, host context,
|
|
2898
|
+
* the agent endpoint, storage, and callbacks are deliberately excluded
|
|
2899
|
+
* because they are client concerns. `presentation.iframe` remains a
|
|
2900
|
+
* server-pushable widget setting.
|
|
2920
2901
|
*
|
|
2921
2902
|
* Two deltas vs the editable surface:
|
|
2922
2903
|
* - `forms` is omitted — resolved form definitions are served by the
|
|
@@ -3109,10 +3090,6 @@ declare const serverConfigSchema: z.ZodObject<{
|
|
|
3109
3090
|
server: "server";
|
|
3110
3091
|
disabled: "disabled";
|
|
3111
3092
|
}>>;
|
|
3112
|
-
tools: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
3113
|
-
code: z.ZodString;
|
|
3114
|
-
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
3115
|
-
}, z.core.$loose>]>>>;
|
|
3116
3093
|
disableHumanInLoop: z.ZodDefault<z.ZodBoolean>;
|
|
3117
3094
|
enableOperatorRequest: z.ZodDefault<z.ZodBoolean>;
|
|
3118
3095
|
}, z.core.$loose>>>;
|
|
@@ -3399,10 +3376,6 @@ declare const handshakeResponseSchema: z.ZodObject<{
|
|
|
3399
3376
|
server: "server";
|
|
3400
3377
|
disabled: "disabled";
|
|
3401
3378
|
}>>;
|
|
3402
|
-
tools: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
3403
|
-
code: z.ZodString;
|
|
3404
|
-
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
3405
|
-
}, z.core.$loose>]>>>;
|
|
3406
3379
|
disableHumanInLoop: z.ZodDefault<z.ZodBoolean>;
|
|
3407
3380
|
enableOperatorRequest: z.ZodDefault<z.ZodBoolean>;
|
|
3408
3381
|
}, z.core.$loose>>>;
|
|
@@ -3593,7 +3566,7 @@ interface ChatWidgetInstance {
|
|
|
3593
3566
|
*
|
|
3594
3567
|
* @example Single widget (default):
|
|
3595
3568
|
* ```ts
|
|
3596
|
-
* mount({ publicKey, mode: 'inline', target: document.getElementById('chat') });
|
|
3569
|
+
* mount({ publicKey, presentation: { mode: 'inline' }, target: document.getElementById('chat') });
|
|
3597
3570
|
* ```
|
|
3598
3571
|
* @example Two widgets on one page:
|
|
3599
3572
|
* ```ts
|