@trillet-ai/web-sdk 1.12.0 → 1.13.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.
@@ -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;
@@ -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;
@@ -1501,6 +1502,11 @@ var TrilletWidgetElement = class extends HTMLElement {
1501
1502
  const session = this.config.mode === "both" ? "multimodal" : mode;
1502
1503
  this.notice = null;
1503
1504
  if (!this.switching) this.display = null;
1505
+ const variables = {
1506
+ ...this.config.dynamicVariablePresets,
1507
+ ...this.dynamicVariableValues,
1508
+ ...this.config.variables
1509
+ };
1504
1510
  const generation = ++this.callGeneration;
1505
1511
  this.setState("connecting");
1506
1512
  try {
@@ -1510,20 +1516,14 @@ var TrilletWidgetElement = class extends HTMLElement {
1510
1516
  apiBaseUrl: this.config.apiBase,
1511
1517
  mode: session,
1512
1518
  startWithVoice: session === "multimodal" && mode === "voice",
1513
- // Presets, then what the visitor just told us, then an explicit `variables`/
1514
- // `dynamic-variables` attribute (power-user override) wins over both.
1515
- variables: {
1516
- ...this.config.dynamicVariablePresets,
1517
- ...this.dynamicVariableValues,
1518
- ...this.config.variables
1519
- }
1519
+ variables
1520
1520
  });
1521
1521
  this.agent = agent;
1522
1522
  this.wireAgentEvents(agent);
1523
1523
  if (this.config.signedUrlEndpoint || this.getRoomDetails) {
1524
1524
  let details;
1525
1525
  if (this.getRoomDetails) {
1526
- details = await this.getRoomDetails({ mode, session });
1526
+ details = await this.getRoomDetails({ mode, session, variables });
1527
1527
  } else {
1528
1528
  const res = await fetch(this.config.signedUrlEndpoint, {
1529
1529
  method: "GET",
@@ -1849,7 +1849,7 @@ var TrilletWidgetElement = class extends HTMLElement {
1849
1849
  card.setAttribute("aria-label", this.config.copy.continueText);
1850
1850
  const title = document.createElement("div");
1851
1851
  title.className = "tw-card-title";
1852
- title.textContent = this.headerTitle() || this.config.copy.chooseModePrompt;
1852
+ title.textContent = this.config.copy.termsTitle;
1853
1853
  card.appendChild(title);
1854
1854
  const entries = [];
1855
1855
  const submit = document.createElement("button");
@@ -1891,6 +1891,13 @@ var TrilletWidgetElement = class extends HTMLElement {
1891
1891
  label.className = "tw-field-label";
1892
1892
  label.htmlFor = inputId;
1893
1893
  label.textContent = prompt.label || prompt.key;
1894
+ if (prompt.required) {
1895
+ const required = document.createElement("span");
1896
+ required.className = "tw-field-required";
1897
+ required.textContent = "*";
1898
+ required.setAttribute("aria-hidden", "true");
1899
+ label.appendChild(required);
1900
+ }
1894
1901
  field.appendChild(label);
1895
1902
  const input = document.createElement("input");
1896
1903
  input.type = "text";
@@ -1898,6 +1905,7 @@ var TrilletWidgetElement = class extends HTMLElement {
1898
1905
  input.className = "tw-field-input";
1899
1906
  if (prompt.placeholder) input.placeholder = prompt.placeholder;
1900
1907
  if (prompt.required) input.required = true;
1908
+ input.setAttribute("aria-required", prompt.required ? "true" : "false");
1901
1909
  input.setAttribute("aria-describedby", errId);
1902
1910
  input.addEventListener("keydown", (event) => {
1903
1911
  if (event.key === "Enter") {