@helpai/elements 0.25.0 → 0.26.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 +2 -2
- package/configurator.mjs +13 -14
- package/elements-web-component.esm.js +19 -19
- package/elements-web-component.esm.js.map +4 -4
- package/elements.cjs.js +19 -19
- package/elements.cjs.js.map +4 -4
- package/elements.esm.js +19 -19
- package/elements.esm.js.map +4 -4
- package/elements.js +19 -19
- package/elements.js.map +4 -4
- package/index.d.ts +37 -83
- package/index.mjs +132 -125
- package/package.json +1 -1
- package/schema.d.ts +50 -50
- package/schema.json +19 -22
- package/schema.mjs +15 -16
- package/web-component.d.ts +1 -1
- package/web-component.mjs +132 -125
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,
|
|
1
|
+
export { A as Asset, B as BlocksConfig, C as ConnectionConfig, a as ConnectionConfigPartial, H as HandshakeResponse, L as Link, S as ServerConfig, b as SiteConfig, W as WidgetConfig, c as WidgetConfigPartial, d as WidgetSettings, e as WidgetSettingsPartial } from './deployment-2pMWV4oW.js';
|
|
2
2
|
import 'zod';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -113,73 +113,11 @@ interface UserPrefs {
|
|
|
113
113
|
textSize?: "small" | "normal" | "large";
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
/**
|
|
117
|
-
* A human-in-the-loop approval decision on a tool call. Mirrors AI SDK v6's
|
|
118
|
-
* `ToolUIPart.approval`: `id` correlates the request ↔ response; `approved`
|
|
119
|
-
* is filled once the user decides; `reason` is an optional note.
|
|
120
|
-
*/
|
|
121
|
-
interface ToolApproval {
|
|
122
|
-
id: string;
|
|
123
|
-
approved?: boolean;
|
|
124
|
-
reason?: string;
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Lifecycle of a tool part. `input` — args streaming. `awaiting` —
|
|
128
|
-
* server-executed tool waiting on output. `awaiting-input` — the ask-input
|
|
129
|
-
* tool waiting on the user's inline-form answer. `awaiting-approval` — a gated
|
|
130
|
-
* action waiting on approve/reject. `output` — resolved. `error` — failed.
|
|
131
|
-
*/
|
|
132
|
-
type ToolState = "input" | "awaiting" | "awaiting-input" | "awaiting-approval" | "output" | "error";
|
|
133
|
-
|
|
134
116
|
/** A tool reference on the wire: `{ code, config }`. `config` is opaque. */
|
|
135
117
|
interface ToolRef {
|
|
136
118
|
code: string;
|
|
137
119
|
config?: Record<string, unknown>;
|
|
138
120
|
}
|
|
139
|
-
interface WireMessage {
|
|
140
|
-
id: string;
|
|
141
|
-
role: "user" | "assistant" | "system";
|
|
142
|
-
parts: WirePart[];
|
|
143
|
-
/**
|
|
144
|
-
* ISO-8601 timestamp the message was created (a serialized Mongo ISODate,
|
|
145
|
-
* e.g. `2026-06-10T07:50:55.816Z`) — every wire date uses this format.
|
|
146
|
-
* Optional so older backends still parse; when present, the widget shows
|
|
147
|
-
* the real send time (and groups messages by day) on reload instead of
|
|
148
|
-
* falling back to "now". Parse with {@link parseWireDate}.
|
|
149
|
-
*/
|
|
150
|
-
createdAt?: string;
|
|
151
|
-
}
|
|
152
|
-
type WirePart = {
|
|
153
|
-
type: "text";
|
|
154
|
-
text: string;
|
|
155
|
-
} | {
|
|
156
|
-
type: "file";
|
|
157
|
-
/** Canonical URL. May be a custom scheme (e.g. `library-id://<id>`). */
|
|
158
|
-
url: string;
|
|
159
|
-
mediaType: string;
|
|
160
|
-
/** Original filename as uploaded. */
|
|
161
|
-
filename?: string;
|
|
162
|
-
/** Opaque id from the upload response — lets the backend dedupe + cache. */
|
|
163
|
-
fileId?: string;
|
|
164
|
-
/** Size in bytes. */
|
|
165
|
-
fileSize?: number;
|
|
166
|
-
} | {
|
|
167
|
-
/**
|
|
168
|
-
* A tool call on the wire. Carries the resolved result up to the backend
|
|
169
|
-
* on a HITL re-POST: the ask-input answer rides in `output`, an approval
|
|
170
|
-
* decision in `approval`. Sent up only for parts the user has acted on
|
|
171
|
-
* (state `output`/`error`/`awaiting-approval` with a decision); in-flight
|
|
172
|
-
* tool parts are not re-serialized. Aligns with AI SDK v6 tool parts.
|
|
173
|
-
*/
|
|
174
|
-
type: "tool";
|
|
175
|
-
toolCallId: string;
|
|
176
|
-
toolName: string;
|
|
177
|
-
state: ToolState;
|
|
178
|
-
input?: unknown;
|
|
179
|
-
output?: unknown;
|
|
180
|
-
errorText?: string;
|
|
181
|
-
approval?: ToolApproval;
|
|
182
|
-
};
|
|
183
121
|
/** One-shot bot persona shown in the panel header. */
|
|
184
122
|
interface ConversationAgent {
|
|
185
123
|
name: string;
|
|
@@ -208,8 +146,12 @@ interface ConversationWelcome {
|
|
|
208
146
|
suggestions?: ConversationSuggestion[];
|
|
209
147
|
}
|
|
210
148
|
/**
|
|
211
|
-
* Response from `POST /ai
|
|
212
|
-
*
|
|
149
|
+
* Response from `POST /ai-agent/handshake` — the widget's one mount-time
|
|
150
|
+
* round-trip. Deliberately LIGHT: identity + deployment surface only
|
|
151
|
+
* (config, agent persona, welcome, page-mode site/blocks, userPrefs).
|
|
152
|
+
* The conversation THREAD is a separate, lazily-fetched read
|
|
153
|
+
* (`GET /conversation`) that only runs once the widget is activated
|
|
154
|
+
* (opened) — a closed launcher costs the page exactly one request.
|
|
213
155
|
*
|
|
214
156
|
* The `userPrefs` field (when present) is the server's authoritative
|
|
215
157
|
* copy of per-visitor preferences — the client should adopt it and update
|
|
@@ -217,14 +159,13 @@ interface ConversationWelcome {
|
|
|
217
159
|
* widget in French when they open it on their laptop (assuming the same
|
|
218
160
|
* `visitorId`, e.g. via authenticated conversation — out of scope for v1).
|
|
219
161
|
*/
|
|
220
|
-
interface
|
|
162
|
+
interface HandshakeResponse {
|
|
221
163
|
/**
|
|
222
164
|
* Public runtime conversation id. The widget mints this UUIDv7 and the backend
|
|
223
165
|
* validates that it belongs to the public deployment + visitor.
|
|
224
166
|
*/
|
|
225
167
|
conversationId: string;
|
|
226
168
|
visitorId?: string;
|
|
227
|
-
canContinue?: boolean;
|
|
228
169
|
/** Bot persona in the panel header (name, avatar, status). */
|
|
229
170
|
agent?: ConversationAgent;
|
|
230
171
|
/** Initial assistant messages + quick-reply chips. */
|
|
@@ -240,7 +181,6 @@ interface StartConversationResponse {
|
|
|
240
181
|
site?: Record<string, unknown>;
|
|
241
182
|
/** Page-mode sidebar blocks (navigation, link cards). Backend ships it whenever the deployment renders the page-shell sidebar. */
|
|
242
183
|
blocks?: Record<string, unknown>;
|
|
243
|
-
messages?: WireMessage[];
|
|
244
184
|
/**
|
|
245
185
|
* Server's authoritative copy of the visitor's preferences. When present,
|
|
246
186
|
* client adopts it (overrides local cache) and re-applies it to the UI
|
|
@@ -292,7 +232,7 @@ type Position = "bottom-right" | "bottom-left" | "top-right" | "top-left";
|
|
|
292
232
|
* `"12px"` horizontal — restore the legacy full-edge
|
|
293
233
|
* slab with `size: { width: "100vw", height: "100vh", inset: "0" }`.
|
|
294
234
|
*
|
|
295
|
-
* Page mode reads `site` and `blocks` from the
|
|
235
|
+
* Page mode reads `site` and `blocks` from the handshake response.
|
|
296
236
|
*/
|
|
297
237
|
type Mode = "floating" | "inline" | "standalone" | "page" | "modal" | "drawer";
|
|
298
238
|
/** End-user text-size preference — scales the whole type ramp. */
|
|
@@ -961,9 +901,9 @@ interface PageContext {
|
|
|
961
901
|
* like a CDN presign service).
|
|
962
902
|
*/
|
|
963
903
|
interface Endpoints {
|
|
964
|
-
/** File upload endpoint. Default: `'/ai
|
|
904
|
+
/** File upload endpoint. Default: `'/ai-agent/upload-file'`. */
|
|
965
905
|
upload?: string;
|
|
966
|
-
/** Voice transcription endpoint. Default: `'/ai
|
|
906
|
+
/** Voice transcription endpoint. Default: `'/ai-agent/transcribe-audio'`. */
|
|
967
907
|
transcribe?: string;
|
|
968
908
|
/**
|
|
969
909
|
* Form submission endpoint. Default: `'/submit-form'`. When any form
|
|
@@ -1010,7 +950,7 @@ interface TrackingOptions {
|
|
|
1010
950
|
/**
|
|
1011
951
|
* Anti-forgery token, echoed as `tk=` on every hit. **Server-issued,
|
|
1012
952
|
* never set by hand** — the backend mints it in the
|
|
1013
|
-
* `/
|
|
953
|
+
* `/handshake` response (HMAC over `pk`/`vid`/expiry with a
|
|
1014
954
|
* server-side secret; see `docs/api/tracking-collector.md`) and the
|
|
1015
955
|
* collector verifies it statelessly. Opaque to the client.
|
|
1016
956
|
*/
|
|
@@ -1027,7 +967,7 @@ interface ResolvedTracking {
|
|
|
1027
967
|
/**
|
|
1028
968
|
* The three composing roots: raw input ({@link ChatWidgetOptions}),
|
|
1029
969
|
* post-normalisation runtime shape ({@link ResolvedOptions}), and the
|
|
1030
|
-
* subset the server can push back via `/
|
|
970
|
+
* subset the server can push back via `/handshake` ({@link
|
|
1031
971
|
* ServerConfig}).
|
|
1032
972
|
*
|
|
1033
973
|
* Internal modules always depend on `ResolvedOptions`. The raw shape
|
|
@@ -1066,14 +1006,26 @@ interface ChatWidgetOptions {
|
|
|
1066
1006
|
aiAgentDeploymentId?: string;
|
|
1067
1007
|
/**
|
|
1068
1008
|
* MAIN site origin (no trailing slash, e.g. `https://help.ai`). The API
|
|
1069
|
-
* modules derive from it
|
|
1070
|
-
* the data API at `${baseUrl}/api/data`.
|
|
1009
|
+
* modules derive from it — the production edge mounts the agent API at
|
|
1010
|
+
* `${baseUrl}/api/agent` and the data API at `${baseUrl}/api/data`.
|
|
1011
|
+
* Defaults to the brand's origin.
|
|
1071
1012
|
*/
|
|
1072
1013
|
baseUrl?: string;
|
|
1014
|
+
/**
|
|
1015
|
+
* Agent-API base (no trailing slash) — set it when the
|
|
1016
|
+
* `module-help-ai-agent-api` service is reached DIRECTLY (a standalone
|
|
1017
|
+
* local module, e.g. `http://localhost:3087`) instead of through the
|
|
1018
|
+
* edge. Routes attach as-is (`${agentBaseUrl}/ai-agent/handshake`).
|
|
1019
|
+
* Precedence: this option > derived from the main origin
|
|
1020
|
+
* (`${baseUrl}/api/agent`). Not server-pushable — the handshake already
|
|
1021
|
+
* travelled over it.
|
|
1022
|
+
*/
|
|
1023
|
+
agentBaseUrl?: string;
|
|
1073
1024
|
/**
|
|
1074
1025
|
* Data-API base (no trailing slash) — the `module-help-ai-data-api`
|
|
1075
1026
|
* service serving content, form definitions, and form submissions at
|
|
1076
1027
|
* root-level paths (`/content`, `/forms`, `/activity`, `/submit-form`).
|
|
1028
|
+
* Set it for a standalone local module (e.g. `http://localhost:3106`).
|
|
1077
1029
|
* Precedence: this option > server-pushed `config.dataBaseUrl` > derived
|
|
1078
1030
|
* from the main origin (`${baseUrl}/api/data`, e.g.
|
|
1079
1031
|
* `https://help.ai/api/data`).
|
|
@@ -1133,6 +1085,8 @@ interface ResolvedOptions {
|
|
|
1133
1085
|
publicKey?: string;
|
|
1134
1086
|
aiAgentDeploymentId?: string;
|
|
1135
1087
|
baseUrl: string;
|
|
1088
|
+
/** Resolved agent-API base — see {@link ChatWidgetOptions.agentBaseUrl}. */
|
|
1089
|
+
agentBaseUrl: string;
|
|
1136
1090
|
/** Resolved data-API base — see {@link ChatWidgetOptions.dataBaseUrl}. */
|
|
1137
1091
|
dataBaseUrl: string;
|
|
1138
1092
|
userContext?: UserContext;
|
|
@@ -1221,7 +1175,7 @@ interface ResolvedOptions {
|
|
|
1221
1175
|
onError?: ChatWidgetOptions["onError"];
|
|
1222
1176
|
}
|
|
1223
1177
|
/**
|
|
1224
|
-
* Shape of the server-pushed `widget` object in `
|
|
1178
|
+
* Shape of the server-pushed `widget` object in `HandshakeResponse`.
|
|
1225
1179
|
*
|
|
1226
1180
|
* Matches a subset of {@link ChatWidgetOptions} — anything the server can
|
|
1227
1181
|
* reasonably dictate (UI, behaviour, routing). Callbacks (`onMessage` etc.)
|
|
@@ -1395,18 +1349,18 @@ interface EventMap {
|
|
|
1395
1349
|
/** An unhandled error occurred somewhere in the transport or UI. */
|
|
1396
1350
|
error: unknown;
|
|
1397
1351
|
/** Connect bootstrap succeeded. Payload is the typed server response. */
|
|
1398
|
-
|
|
1352
|
+
handshake: HandshakeResponse;
|
|
1399
1353
|
/**
|
|
1400
1354
|
* Server rebound the `visitorId` — e.g. the client-minted id
|
|
1401
1355
|
* conflicted with an existing record, was expired, or otherwise
|
|
1402
1356
|
* rejected, and the server returned a fresh one in the
|
|
1403
|
-
* `/
|
|
1357
|
+
* `/handshake` response. The widget has already adopted the new
|
|
1404
1358
|
* id and persisted it; this event is informational so host pages
|
|
1405
1359
|
* can re-link analytics / external systems that pinned the
|
|
1406
1360
|
* previous value.
|
|
1407
1361
|
*
|
|
1408
1362
|
* `reason` is the server's explanation, when provided
|
|
1409
|
-
* (`rebind.visitorId` in the
|
|
1363
|
+
* (`rebind.visitorId` in the handshake response). Common values:
|
|
1410
1364
|
* `"conflict"` / `"expired"` / `"invalid"`. May be `undefined` if
|
|
1411
1365
|
* the server didn't include a `rebind` block.
|
|
1412
1366
|
*/
|
|
@@ -1535,7 +1489,7 @@ interface ChatWidgetInstance {
|
|
|
1535
1489
|
expand: () => void;
|
|
1536
1490
|
/**
|
|
1537
1491
|
* Open the widget in a new browser tab at `behavior.popOutUrl`
|
|
1538
|
-
* (mount option /
|
|
1492
|
+
* (mount option / handshake-pushable), or the brand's
|
|
1539
1493
|
* `BRAND.standaloneUrl` build-time default. Carries the active
|
|
1540
1494
|
* `chat` + `widgetId` as query params. No-ops when the resolved
|
|
1541
1495
|
* URL is empty.
|
|
@@ -1551,7 +1505,7 @@ interface ChatWidgetInstance {
|
|
|
1551
1505
|
* Subscribe to a lifecycle event. Returns an `off` function. See
|
|
1552
1506
|
* {@link EventMap} for the full set + payload shapes — currently
|
|
1553
1507
|
* `open | close | message | error | expand | fullscreen | popOut |
|
|
1554
|
-
*
|
|
1508
|
+
* handshake | localeChange`.
|
|
1555
1509
|
*/
|
|
1556
1510
|
on: <E extends EventName>(name: E, fn: (payload: EventMap[E]) => void) => () => void;
|
|
1557
1511
|
/**
|
|
@@ -1572,7 +1526,7 @@ interface ChatWidgetInstance {
|
|
|
1572
1526
|
* ```
|
|
1573
1527
|
*/
|
|
1574
1528
|
setUserContext: (userContext: UserContext) => void;
|
|
1575
|
-
/** Clear the end-user context (e.g. on logout) and re-
|
|
1529
|
+
/** Clear the end-user context (e.g. on logout) and re-handshake anonymously. */
|
|
1576
1530
|
clearUserContext: () => void;
|
|
1577
1531
|
/**
|
|
1578
1532
|
* Set / merge the host-asserted page/visit context (`area`, `url`, `path`,
|
|
@@ -1586,7 +1540,7 @@ interface ChatWidgetInstance {
|
|
|
1586
1540
|
* ```
|
|
1587
1541
|
*/
|
|
1588
1542
|
setPageContext: (pageContext: PageContext) => void;
|
|
1589
|
-
/** Clear the page/visit context and re-
|
|
1543
|
+
/** Clear the page/visit context and re-handshake. */
|
|
1590
1544
|
clearPageContext: () => void;
|
|
1591
1545
|
/**
|
|
1592
1546
|
* Set the runtime log level. Accepts `"off"` / `"error"` / `"warn"` /
|