@trillet-ai/web-sdk 1.12.0 → 1.13.1
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/dist/widget/index.d.ts +8 -0
- package/dist/widget/index.js +18 -9
- package/dist/widget/index.js.map +1 -1
- package/dist/widget.umd.js +3 -1
- package/dist/widget.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/widget/index.d.ts
CHANGED
|
@@ -339,6 +339,14 @@ declare class TrilletWidgetElement extends HTMLElement {
|
|
|
339
339
|
mode: ActiveMode;
|
|
340
340
|
/** Session type to mint: `multimodal` for mode="both" (type or talk). */
|
|
341
341
|
session: SessionMode;
|
|
342
|
+
/**
|
|
343
|
+
* Presets plus whatever the visitor just entered, resolved for this
|
|
344
|
+
* conversation. A room minted here is built before the widget can send
|
|
345
|
+
* anything itself, so a minting endpoint has to forward these as
|
|
346
|
+
* `dynamic_variables` or the agent never sees them and `{{key}}` stays
|
|
347
|
+
* literal in the prompt.
|
|
348
|
+
*/
|
|
349
|
+
variables: Record<string, unknown>;
|
|
342
350
|
}) => Promise<TrilletRoomDetails> | TrilletRoomDetails;
|
|
343
351
|
roomDetails?: TrilletRoomDetails;
|
|
344
352
|
private durationTimer;
|
package/dist/widget/index.js
CHANGED
|
@@ -1019,6 +1019,7 @@ svg { display: block; flex-shrink: 0; }
|
|
|
1019
1019
|
.tw-variables-form { width: 320px; }
|
|
1020
1020
|
.tw-field { display: flex; flex-direction: column; gap: 4px; }
|
|
1021
1021
|
.tw-field-label { font-size: 13px; font-weight: 500; color: var(--tw-muted); }
|
|
1022
|
+
.tw-field-required { color: var(--tw-danger); margin-left: 2px; }
|
|
1022
1023
|
.tw-field-input {
|
|
1023
1024
|
height: 38px;
|
|
1024
1025
|
padding: 0 10px;
|
|
@@ -1029,6 +1030,7 @@ svg { display: block; flex-shrink: 0; }
|
|
|
1029
1030
|
font: inherit;
|
|
1030
1031
|
font-size: 14px;
|
|
1031
1032
|
}
|
|
1033
|
+
.tw-field-input::placeholder { color: var(--tw-muted); }
|
|
1032
1034
|
.tw-field-input:focus-visible { outline: none; border-color: var(--tw-accent); }
|
|
1033
1035
|
.tw-field-error { margin: 0; font-size: 12px; color: var(--tw-danger); }
|
|
1034
1036
|
.tw-variables-form .tw-pill {
|
|
@@ -1501,6 +1503,11 @@ var TrilletWidgetElement = class extends HTMLElement {
|
|
|
1501
1503
|
const session = this.config.mode === "both" ? "multimodal" : mode;
|
|
1502
1504
|
this.notice = null;
|
|
1503
1505
|
if (!this.switching) this.display = null;
|
|
1506
|
+
const variables = {
|
|
1507
|
+
...this.config.dynamicVariablePresets,
|
|
1508
|
+
...this.dynamicVariableValues,
|
|
1509
|
+
...this.config.variables
|
|
1510
|
+
};
|
|
1504
1511
|
const generation = ++this.callGeneration;
|
|
1505
1512
|
this.setState("connecting");
|
|
1506
1513
|
try {
|
|
@@ -1510,20 +1517,14 @@ var TrilletWidgetElement = class extends HTMLElement {
|
|
|
1510
1517
|
apiBaseUrl: this.config.apiBase,
|
|
1511
1518
|
mode: session,
|
|
1512
1519
|
startWithVoice: session === "multimodal" && mode === "voice",
|
|
1513
|
-
|
|
1514
|
-
// `dynamic-variables` attribute (power-user override) wins over both.
|
|
1515
|
-
variables: {
|
|
1516
|
-
...this.config.dynamicVariablePresets,
|
|
1517
|
-
...this.dynamicVariableValues,
|
|
1518
|
-
...this.config.variables
|
|
1519
|
-
}
|
|
1520
|
+
variables
|
|
1520
1521
|
});
|
|
1521
1522
|
this.agent = agent;
|
|
1522
1523
|
this.wireAgentEvents(agent);
|
|
1523
1524
|
if (this.config.signedUrlEndpoint || this.getRoomDetails) {
|
|
1524
1525
|
let details;
|
|
1525
1526
|
if (this.getRoomDetails) {
|
|
1526
|
-
details = await this.getRoomDetails({ mode, session });
|
|
1527
|
+
details = await this.getRoomDetails({ mode, session, variables });
|
|
1527
1528
|
} else {
|
|
1528
1529
|
const res = await fetch(this.config.signedUrlEndpoint, {
|
|
1529
1530
|
method: "GET",
|
|
@@ -1849,7 +1850,7 @@ var TrilletWidgetElement = class extends HTMLElement {
|
|
|
1849
1850
|
card.setAttribute("aria-label", this.config.copy.continueText);
|
|
1850
1851
|
const title = document.createElement("div");
|
|
1851
1852
|
title.className = "tw-card-title";
|
|
1852
|
-
title.textContent = this.
|
|
1853
|
+
title.textContent = this.config.copy.termsTitle;
|
|
1853
1854
|
card.appendChild(title);
|
|
1854
1855
|
const entries = [];
|
|
1855
1856
|
const submit = document.createElement("button");
|
|
@@ -1891,6 +1892,13 @@ var TrilletWidgetElement = class extends HTMLElement {
|
|
|
1891
1892
|
label.className = "tw-field-label";
|
|
1892
1893
|
label.htmlFor = inputId;
|
|
1893
1894
|
label.textContent = prompt.label || prompt.key;
|
|
1895
|
+
if (prompt.required) {
|
|
1896
|
+
const required = document.createElement("span");
|
|
1897
|
+
required.className = "tw-field-required";
|
|
1898
|
+
required.textContent = "*";
|
|
1899
|
+
required.setAttribute("aria-hidden", "true");
|
|
1900
|
+
label.appendChild(required);
|
|
1901
|
+
}
|
|
1894
1902
|
field.appendChild(label);
|
|
1895
1903
|
const input = document.createElement("input");
|
|
1896
1904
|
input.type = "text";
|
|
@@ -1898,6 +1906,7 @@ var TrilletWidgetElement = class extends HTMLElement {
|
|
|
1898
1906
|
input.className = "tw-field-input";
|
|
1899
1907
|
if (prompt.placeholder) input.placeholder = prompt.placeholder;
|
|
1900
1908
|
if (prompt.required) input.required = true;
|
|
1909
|
+
input.setAttribute("aria-required", prompt.required ? "true" : "false");
|
|
1901
1910
|
input.setAttribute("aria-describedby", errId);
|
|
1902
1911
|
input.addEventListener("keydown", (event) => {
|
|
1903
1912
|
if (event.key === "Enter") {
|