@helpai/elements 0.14.1 → 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/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 StartSessionResponse, W as WidgetConfig, d as WidgetConfigPartial, e as WidgetSettings, f as WidgetSettingsPartial } from './deployment-DYIboFNT.js';
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
  /**
@@ -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. **`sessionId`** — the active conversation thread. The backend is the
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.loadSession()`.
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 SessionAgent {
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 SessionSuggestion {
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 SessionWelcome {
198
+ interface ConversationWelcome {
199
199
  messages?: Array<{
200
200
  id: string;
201
201
  role: "assistant" | "system";
202
202
  text: string;
203
203
  }>;
204
- suggestions?: SessionSuggestion[];
204
+ suggestions?: ConversationSuggestion[];
205
205
  }
206
206
  /**
207
- * Response from `POST /ai/agent/start-session`. Every field is optional so the
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 session — out of scope for v1).
214
+ * `visitorId`, e.g. via authenticated conversation — out of scope for v1).
215
215
  */
216
- interface StartSessionResponse {
216
+ interface StartConversationResponse {
217
217
  /**
218
- * Public runtime session id. The widget mints this UUIDv7 and the backend
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
- sessionId: string;
221
+ conversationId: string;
222
222
  visitorId?: string;
223
223
  canContinue?: boolean;
224
224
  /** Bot persona in the panel header (name, avatar, status). */
225
- agent?: SessionAgent;
225
+ agent?: ConversationAgent;
226
226
  /** Initial assistant messages + quick-reply chips. */
227
- welcome?: SessionWelcome;
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
- * `sessionId` different from what the client sent, this block tells
248
+ * `conversationId` different from what the client sent, this block tells
249
249
  * the client WHY — useful for telemetry and the `visitorRebound` /
250
- * `sessionRebound` events fired into the host page. Server is free to
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
- sessionId?: string;
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-session response.
291
+ * Page mode reads `site` and `blocks` from the start-conversation response.
292
292
  */
293
293
  type Mode = "floating" | "inline" | "standalone" | "page" | "modal" | "drawer";
294
294
  /** Theme preference. `auto` follows `prefers-color-scheme`. */
@@ -533,8 +533,11 @@ interface FormCondition {
533
533
  minMessages?: number;
534
534
  maxMessages?: number;
535
535
  }
536
- /** How often a form may show. */
537
- type FormFrequency = "once" | "session" | "always";
536
+ /**
537
+ * How often a form may show: `once` per device (persisted), once per
538
+ * `conversation` (re-eligible when a new conversation starts), or `always`.
539
+ */
540
+ type FormFrequency = "once" | "conversation" | "always";
538
541
  /** One form as authored in config (raw input). */
539
542
  interface FormDef {
540
543
  /** Stable id — persistence dedupe + `manual` `openForm(id)`. */
@@ -953,7 +956,7 @@ interface Endpoints {
953
956
  * Form submission endpoint. Default: `'/ai/agent/submit-form'`. When any form
954
957
  * (a pre-chat lead capture, a CSAT survey, etc.) is completed, the widget POSTs
955
958
  * the captured values here (fire-and-forget), keyed by the same `visitorId` +
956
- * `sessionId` the conversation uses; the payload carries `formId` + `trigger`
959
+ * `conversationId` the conversation uses; the payload carries `formId` + `trigger`
957
960
  * so the backend can route. Optional: a backend that doesn't implement it just
958
961
  * 404s and the submission is ignored.
959
962
  */
@@ -963,7 +966,7 @@ interface Endpoints {
963
966
  /**
964
967
  * The three composing roots: raw input ({@link ChatWidgetOptions}),
965
968
  * post-normalisation runtime shape ({@link ResolvedOptions}), and the
966
- * subset the server can push back via `/start-session` ({@link
969
+ * subset the server can push back via `/start-conversation` ({@link
967
970
  * ServerConfig}).
968
971
  *
969
972
  * Internal modules always depend on `ResolvedOptions`. The raw shape
@@ -992,7 +995,7 @@ interface ChatWidgetOptions {
992
995
  /**
993
996
  * Stable identifier for this widget instance. Use when mounting more
994
997
  * than one widget on the same page (different deployments, different
995
- * targets). Isolates client-storage namespaces (visitorId, active sessionId,
998
+ * targets). Isolates client-storage namespaces (visitorId, active conversationId,
996
999
  * cached userPrefs). Default: `"default"`.
997
1000
  */
998
1001
  widgetId?: string;
@@ -1138,7 +1141,7 @@ interface ResolvedOptions {
1138
1141
  onError?: ChatWidgetOptions["onError"];
1139
1142
  }
1140
1143
  /**
1141
- * Shape of the server-pushed `widget` object in `StartSessionResponse`.
1144
+ * Shape of the server-pushed `widget` object in `StartConversationResponse`.
1142
1145
  *
1143
1146
  * Matches a subset of {@link ChatWidgetOptions} — anything the server can
1144
1147
  * reasonably dictate (UI, behaviour, routing). Callbacks (`onMessage` etc.)
@@ -1246,7 +1249,7 @@ interface EventMap {
1246
1249
  clear: void;
1247
1250
  /** User picked a chat from the history pane / sidebar. */
1248
1251
  selectChat: {
1249
- sessionId: string;
1252
+ conversationId: string;
1250
1253
  };
1251
1254
  /** User clicked a suggested-message chip. */
1252
1255
  suggestion: {
@@ -1305,18 +1308,18 @@ interface EventMap {
1305
1308
  /** An unhandled error occurred somewhere in the transport or UI. */
1306
1309
  error: unknown;
1307
1310
  /** Connect bootstrap succeeded. Payload is the typed server response. */
1308
- sessionStarted: StartSessionResponse;
1311
+ conversationStarted: StartConversationResponse;
1309
1312
  /**
1310
1313
  * Server rebound the `visitorId` — e.g. the client-minted id
1311
1314
  * conflicted with an existing record, was expired, or otherwise
1312
1315
  * rejected, and the server returned a fresh one in the
1313
- * `/start-session` response. The widget has already adopted the new
1316
+ * `/start-conversation` response. The widget has already adopted the new
1314
1317
  * id and persisted it; this event is informational so host pages
1315
1318
  * can re-link analytics / external systems that pinned the
1316
1319
  * previous value.
1317
1320
  *
1318
1321
  * `reason` is the server's explanation, when provided
1319
- * (`rebind.visitorId` in the start-session response). Common values:
1322
+ * (`rebind.visitorId` in the start-conversation response). Common values:
1320
1323
  * `"conflict"` / `"expired"` / `"invalid"`. May be `undefined` if
1321
1324
  * the server didn't include a `rebind` block.
1322
1325
  */
@@ -1326,12 +1329,12 @@ interface EventMap {
1326
1329
  reason?: string;
1327
1330
  };
1328
1331
  /**
1329
- * Server rebound the `sessionId` — same shape and semantics as
1332
+ * Server rebound the `conversationId` — same shape and semantics as
1330
1333
  * `visitorRebound` but for the conversation-thread id. Fires when
1331
- * the server's response carries a different `sessionId` than the
1334
+ * the server's response carries a different `conversationId` than the
1332
1335
  * client sent.
1333
1336
  */
1334
- sessionRebound: {
1337
+ conversationRebound: {
1335
1338
  previous: string;
1336
1339
  current: string;
1337
1340
  reason?: string;
@@ -1445,7 +1448,7 @@ interface ChatWidgetInstance {
1445
1448
  expand: () => void;
1446
1449
  /**
1447
1450
  * Open the widget in a new browser tab at `behavior.popOutUrl`
1448
- * (mount option / start-session-pushable), or the brand's
1451
+ * (mount option / start-conversation-pushable), or the brand's
1449
1452
  * `BRAND.standaloneUrl` build-time default. Carries the active
1450
1453
  * `chat` + `widgetId` as query params. No-ops when the resolved
1451
1454
  * URL is empty.
@@ -1461,7 +1464,7 @@ interface ChatWidgetInstance {
1461
1464
  * Subscribe to a lifecycle event. Returns an `off` function. See
1462
1465
  * {@link EventMap} for the full set + payload shapes — currently
1463
1466
  * `open | close | message | error | expand | fullscreen | popOut |
1464
- * sessionStarted | localeChange`.
1467
+ * conversationStarted | localeChange`.
1465
1468
  */
1466
1469
  on: <E extends EventName>(name: E, fn: (payload: EventMap[E]) => void) => () => void;
1467
1470
  /**
@@ -1482,7 +1485,7 @@ interface ChatWidgetInstance {
1482
1485
  * ```
1483
1486
  */
1484
1487
  setUserContext: (userContext: UserContext) => void;
1485
- /** Clear the end-user context (e.g. on logout) and re-start-session anonymously. */
1488
+ /** Clear the end-user context (e.g. on logout) and re-start-conversation anonymously. */
1486
1489
  clearUserContext: () => void;
1487
1490
  /**
1488
1491
  * Set / merge the host-asserted page/visit context (`area`, `url`, `path`,
@@ -1496,7 +1499,7 @@ interface ChatWidgetInstance {
1496
1499
  * ```
1497
1500
  */
1498
1501
  setPageContext: (pageContext: PageContext) => void;
1499
- /** Clear the page/visit context and re-start-session. */
1502
+ /** Clear the page/visit context and re-start-conversation. */
1500
1503
  clearPageContext: () => void;
1501
1504
  /**
1502
1505
  * Set the runtime log level. Accepts `"off"` / `"error"` / `"warn"` /