@helpai/elements 1.10.0 → 1.12.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/docs/README.md +1 -0
- package/docs/analytics.md +33 -1
- package/docs/api-reference.md +56 -4
- package/docs/configuration.md +18 -0
- package/docs/events-and-hooks.md +13 -11
- package/docs/frameworks.md +4 -1
- package/docs/installation.md +4 -4
- package/docs/page-tools.md +194 -0
- package/docs/security-privacy.md +7 -4
- package/elements-web-component.esm.js +43 -39
- package/elements-web-component.esm.js.map +4 -4
- package/elements.cjs.js +43 -39
- package/elements.cjs.js.map +4 -4
- package/elements.esm.js +43 -39
- package/elements.esm.js.map +4 -4
- package/elements.js +43 -39
- package/elements.js.map +4 -4
- package/index.d.ts +85 -3
- package/index.mjs +15 -14
- package/jsx-react.d.ts +2 -1
- package/jsx-svelte.d.ts +2 -1
- package/jsx-vue.d.ts +3 -2
- package/llms-full.txt +468 -158
- package/llms.txt +21 -18
- package/package.json +3 -3
- package/react.d.ts +101 -3
- package/react.mjs +32 -31
- package/style.css +1 -1
- package/web-component.d.ts +87 -3
- package/web-component.mjs +15 -14
package/index.d.ts
CHANGED
|
@@ -38,7 +38,7 @@ interface ClientStorage {
|
|
|
38
38
|
* populated {@link Strings} map. UI components then read `strings.send` as a
|
|
39
39
|
* normal property access — no per-render lookup, no per-render allocation.
|
|
40
40
|
*/
|
|
41
|
-
type StringKey = 'launcherOpen' | 'launcherLabel' | 'panelTitle' | 'composerPlaceholder' | 'send' | 'stop' | 'queueMessage' | 'removeQueuedMessage' | 'compactingContext' | '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' | 'visualPreparing' | 'visualError' | 'visualPartial' | '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' | 'contentHelpful' | 'homeGreeting' | 'homeGreetingNamed' | 'homeGreetingLead' | 'homeSearchPlaceholder' | 'homeAskPlaceholder' | 'homeWhatsNew' | 'homeContentTitle' | 'homeStatus' | 'helpTitle' | 'helpSearchPlaceholder' | 'helpEmpty' | 'helpLoading' | 'helpSearchEmpty' | 'helpShowMore' | 'newsTitle' | 'newsEmpty' | 'newsLoading' | 'newsBack' | 'newsPublishedAt' | 'newsShowMore' | 'newsUnseen';
|
|
41
|
+
type StringKey = 'launcherOpen' | 'launcherLabel' | 'panelTitle' | 'composerPlaceholder' | 'send' | 'stop' | 'queueMessage' | 'removeQueuedMessage' | 'compactingContext' | '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' | 'visualPreparing' | 'visualError' | 'visualPartial' | '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' | 'statusIncomplete' | 'tabHome' | 'tabConversations' | 'tabHelp' | 'tabNews' | 'modulesEmpty' | 'moduleBack' | 'contentLoading' | 'contentHelpful' | 'homeGreeting' | 'homeGreetingNamed' | 'homeGreetingLead' | 'homeSearchPlaceholder' | 'homeAskPlaceholder' | 'homeWhatsNew' | 'homeContentTitle' | 'homeStatus' | 'helpTitle' | 'helpSearchPlaceholder' | 'helpEmpty' | 'helpLoading' | 'helpSearchEmpty' | 'helpShowMore' | 'newsTitle' | 'newsEmpty' | 'newsLoading' | 'newsBack' | 'newsPublishedAt' | 'newsShowMore' | 'newsUnseen';
|
|
42
42
|
/** A partial map for one locale — what overrides look like on the wire. */
|
|
43
43
|
type LocaleStrings = Partial<Record<StringKey, string>>;
|
|
44
44
|
/**
|
|
@@ -900,6 +900,36 @@ interface ResolvedTracking {
|
|
|
900
900
|
*/
|
|
901
901
|
/** A signed user token, or a function that returns a fresh one (see {@link ChatWidgetOptions.userToken}). */
|
|
902
902
|
type UserTokenSource = string | (() => string | Promise<string>);
|
|
903
|
+
/** WebMCP `ToolAnnotations`: hints about what a tool does. */
|
|
904
|
+
interface ToolAnnotations {
|
|
905
|
+
/** It only reads; it changes nothing. */
|
|
906
|
+
readOnlyHint?: boolean;
|
|
907
|
+
/** Its result holds content the site doesn't vouch for, such as reviews. */
|
|
908
|
+
untrustedContentHint?: boolean;
|
|
909
|
+
/** A significant or irreversible action (booking, paying, deleting): the visitor approves each call first. */
|
|
910
|
+
consequentialHint?: boolean;
|
|
911
|
+
/** Built for developers, not visitors. */
|
|
912
|
+
debugging?: boolean;
|
|
913
|
+
}
|
|
914
|
+
/**
|
|
915
|
+
* A tool the AI agent can use on your page, in the WebMCP `ModelContextTool` shape: the same object works with
|
|
916
|
+
* `document.modelContext.registerTool()`. The agent sees `name`, `description` and `inputSchema`; `execute` runs here,
|
|
917
|
+
* in the visitor's browser, and what it returns goes back to the agent.
|
|
918
|
+
*/
|
|
919
|
+
interface ModelContextTool<TInput = unknown> {
|
|
920
|
+
/** Letters, digits, `_` and `-` (58 at most; others become `_`). A name registered again replaces the earlier tool. */
|
|
921
|
+
name: string;
|
|
922
|
+
title?: string;
|
|
923
|
+
/** When the agent should use it and what it does (1024 characters at most). */
|
|
924
|
+
description: string;
|
|
925
|
+
/** JSON Schema of the input (`type: "object"`); none means the tool takes no input. */
|
|
926
|
+
inputSchema?: Record<string, unknown>;
|
|
927
|
+
annotations?: ToolAnnotations;
|
|
928
|
+
/** Runs the tool: return a JSON value (or a promise of one) for the agent; throw to report a failure. `signal` aborts when the visitor moves on first. */
|
|
929
|
+
execute(input: TInput, options: {
|
|
930
|
+
signal: AbortSignal;
|
|
931
|
+
}): unknown;
|
|
932
|
+
}
|
|
903
933
|
interface ChatWidgetOptions {
|
|
904
934
|
/**
|
|
905
935
|
* Stable identifier for this widget instance. Use when mounting more
|
|
@@ -983,6 +1013,12 @@ interface ChatWidgetOptions {
|
|
|
983
1013
|
* sign-out. Sent only to the agent API, as `x-user-token`.
|
|
984
1014
|
*/
|
|
985
1015
|
userToken?: UserTokenSource;
|
|
1016
|
+
/**
|
|
1017
|
+
* Tools the AI agent can use on your page (open a booking form, read the cart, jump to a section), WebMCP
|
|
1018
|
+
* `ModelContextTool`s. Sent with each message as definitions only; the agent's call runs `execute` here, in the
|
|
1019
|
+
* visitor's browser. `registerTool()` adds one from anywhere, for example a single-page app's route.
|
|
1020
|
+
*/
|
|
1021
|
+
tools?: readonly ModelContextTool[];
|
|
986
1022
|
onMessage?: (msg: {
|
|
987
1023
|
role: string;
|
|
988
1024
|
text: string;
|
|
@@ -1094,12 +1130,15 @@ interface ResolvedOptions {
|
|
|
1094
1130
|
/** Resolved storage adapter — defaults to `LocalStorageAdapter`. */
|
|
1095
1131
|
storage: ClientStorage;
|
|
1096
1132
|
userToken?: UserTokenSource;
|
|
1133
|
+
tools?: readonly ModelContextTool[];
|
|
1097
1134
|
onMessage?: ChatWidgetOptions['onMessage'];
|
|
1098
1135
|
onOpen?: ChatWidgetOptions['onOpen'];
|
|
1099
1136
|
onClose?: ChatWidgetOptions['onClose'];
|
|
1100
1137
|
onError?: ChatWidgetOptions['onError'];
|
|
1101
1138
|
}
|
|
1102
1139
|
type HostMode = 'page' | 'standalone' | 'inline' | 'modal' | 'drawer' | 'fullscreen' | 'expanded' | 'open' | 'closed';
|
|
1140
|
+
/** How a call this page ran (or found cut short) ended, for the `toolResult` event. */
|
|
1141
|
+
type PageToolCallStatus = 'completed' | 'failed' | 'interrupted';
|
|
1103
1142
|
/** A single image asset (logo, hero, icon). */
|
|
1104
1143
|
declare const assetSchema: z.ZodObject<{
|
|
1105
1144
|
url: z.ZodString;
|
|
@@ -3145,15 +3184,27 @@ interface EventMap {
|
|
|
3145
3184
|
values: Record<string, string>;
|
|
3146
3185
|
skipped: boolean;
|
|
3147
3186
|
};
|
|
3148
|
-
/**
|
|
3187
|
+
/**
|
|
3188
|
+
* A tool call settled on the page: the visitor answered an ask-questions request (`toolCallId` only), or a page
|
|
3189
|
+
* tool's call ended — `completed`, `failed`, `declined` or `stopped` by the visitor, or `interrupted` by a reload —
|
|
3190
|
+
* after `durationMs`. Never its input or result.
|
|
3191
|
+
*/
|
|
3149
3192
|
toolResult: {
|
|
3150
3193
|
toolCallId: string;
|
|
3194
|
+
name?: string;
|
|
3195
|
+
status?: PageToolCallStatus | 'declined' | 'stopped';
|
|
3196
|
+
durationMs?: number;
|
|
3151
3197
|
};
|
|
3152
3198
|
/** User approved / rejected a gated tool call (re-POST follows). */
|
|
3153
3199
|
toolDecision: {
|
|
3154
3200
|
toolCallId: string;
|
|
3155
3201
|
approved: boolean;
|
|
3156
3202
|
};
|
|
3203
|
+
/** Your page reported its own event with `track(name, data)`: sent to analytics, and to the agent with the next message. */
|
|
3204
|
+
hostEvent: {
|
|
3205
|
+
name: string;
|
|
3206
|
+
data?: Record<string, string | number | boolean>;
|
|
3207
|
+
};
|
|
3157
3208
|
/**
|
|
3158
3209
|
* User gave feedback on a rateable reply (AI or operator). `value` is `"up"` / `"down"`, or
|
|
3159
3210
|
* `null` when they cleared a prior choice. `messageId` is the backend message
|
|
@@ -3300,6 +3351,8 @@ interface AskOptions {
|
|
|
3300
3351
|
/** Send the text as the visitor's message instead of filling the composer with it. Default `false`. */
|
|
3301
3352
|
send?: boolean;
|
|
3302
3353
|
}
|
|
3354
|
+
/** Flat data about a host event: strings, numbers and booleans only. */
|
|
3355
|
+
type HostEventData = Record<string, string | number | boolean>;
|
|
3303
3356
|
/**
|
|
3304
3357
|
* Comprehensive logger for the widget runtime.
|
|
3305
3358
|
*
|
|
@@ -3406,6 +3459,35 @@ export interface ChatWidgetInstance {
|
|
|
3406
3459
|
* ```
|
|
3407
3460
|
*/
|
|
3408
3461
|
login: (userToken: UserTokenSource) => void;
|
|
3462
|
+
/**
|
|
3463
|
+
* Report something the visitor did on your site, outside the chat. Sends a `hostEvent` hit to analytics (not when
|
|
3464
|
+
* tracking is off), and the agent reads your last 10 events with the visitor's next message. `name` is 1–64
|
|
3465
|
+
* characters; `data` is flat (strings, numbers, booleans), 256 characters of JSON at most.
|
|
3466
|
+
*
|
|
3467
|
+
* @example
|
|
3468
|
+
* ```ts
|
|
3469
|
+
* chat.track('plan_viewed', { plan: 'pro' });
|
|
3470
|
+
* ```
|
|
3471
|
+
*/
|
|
3472
|
+
track: (name: string, data?: HostEventData) => void;
|
|
3473
|
+
/**
|
|
3474
|
+
* Add a tool the agent can use on this page, in the WebMCP tool shape — for every widget on the page, not only this
|
|
3475
|
+
* one. The latest registration of a name wins; aborting `options.signal` removes it. `annotations.consequentialHint`
|
|
3476
|
+
* asks the visitor before each call. See `docs/sdk/page-tools.md`.
|
|
3477
|
+
*
|
|
3478
|
+
* @example
|
|
3479
|
+
* ```ts
|
|
3480
|
+
* chat.registerTool({
|
|
3481
|
+
* name: 'open_booking',
|
|
3482
|
+
* description: 'Open the booking form for a meeting type.',
|
|
3483
|
+
* inputSchema: { type: 'object', properties: { meetingType: { type: 'string', enum: ['sales', 'support'] } }, required: ['meetingType'] },
|
|
3484
|
+
* execute: ({ meetingType }) => booking.open(meetingType),
|
|
3485
|
+
* });
|
|
3486
|
+
* ```
|
|
3487
|
+
*/
|
|
3488
|
+
registerTool: (tool: ModelContextTool, options?: {
|
|
3489
|
+
signal?: AbortSignal;
|
|
3490
|
+
}) => void;
|
|
3409
3491
|
/**
|
|
3410
3492
|
* Subscribe to a lifecycle event. Returns an `off` function. See
|
|
3411
3493
|
* {@link EventMap} for the full set + payload shapes — currently
|
|
@@ -3549,4 +3631,4 @@ export declare const brand: {
|
|
|
3549
3631
|
readonly domain: string;
|
|
3550
3632
|
readonly siteUrl: string;
|
|
3551
3633
|
};
|
|
3552
|
-
export type { AskOptions, Asset, BlocksConfig, ChatWidgetOptions, ConnectionConfig, ConnectionConfigPartial, EventMap, EventName, HandshakeResponse, HookListener, Link, LogEntry, LogLevel, OpenTarget, ResolvedOptions, ServerConfig, SiteConfig, UserTokenSource, WidgetConfig, WidgetConfigPartial, WidgetSettings, WidgetSettingsPartial, WidgetState };
|
|
3634
|
+
export type { AskOptions, Asset, BlocksConfig, ChatWidgetOptions, ConnectionConfig, ConnectionConfigPartial, EventMap, EventName, HandshakeResponse, HookListener, HostEventData, Link, LogEntry, LogLevel, ModelContextTool, OpenTarget, ResolvedOptions, ServerConfig, SiteConfig, ToolAnnotations, UserTokenSource, WidgetConfig, WidgetConfigPartial, WidgetSettings, WidgetSettingsPartial, WidgetState };
|