@oxvo/ai-live-assist 7.5.19 → 7.5.21
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/cjs/AiLiveAssist.d.ts +8 -1
- package/cjs/AiLiveAssist.js +113 -8
- package/cjs/client.d.ts +5 -3
- package/cjs/client.js +44 -5
- package/cjs/commerce/cartContracts.d.ts +158 -0
- package/cjs/commerce/cartContracts.js +228 -0
- package/cjs/commerce/cartSession.d.ts +86 -0
- package/cjs/commerce/cartSession.js +475 -0
- package/cjs/commerce/contracts.d.ts +152 -0
- package/cjs/commerce/contracts.js +322 -0
- package/cjs/commerce/pageContext.d.ts +50 -0
- package/cjs/commerce/pageContext.js +173 -0
- package/cjs/commerce/productPanel.d.ts +65 -0
- package/cjs/commerce/productPanel.js +662 -0
- package/cjs/commerce/realtimeCommerce.d.ts +73 -0
- package/cjs/commerce/realtimeCommerce.js +342 -0
- package/cjs/commerce/shopifyCart.d.ts +130 -0
- package/cjs/commerce/shopifyCart.js +1135 -0
- package/cjs/commerce/shopifyCartPresentation.d.ts +12 -0
- package/cjs/commerce/shopifyCartPresentation.js +379 -0
- package/cjs/commerce/shoppingNotes.d.ts +61 -0
- package/cjs/commerce/shoppingNotes.js +313 -0
- package/cjs/commerce/shoppingNotesView.d.ts +46 -0
- package/cjs/commerce/shoppingNotesView.js +269 -0
- package/cjs/control.d.ts +9 -1
- package/cjs/control.js +51 -1
- package/cjs/guideAdmission.d.ts +5 -2
- package/cjs/guideAdmission.js +21 -2
- package/cjs/guideInstaller.js +1 -1
- package/cjs/guideMeasurement.d.ts +5 -0
- package/cjs/guideMeasurement.js +29 -0
- package/cjs/guideSubjectStore.js +2 -0
- package/cjs/guideTypes.d.ts +18 -0
- package/cjs/liveControlChannel.d.ts +43 -1
- package/cjs/liveControlChannel.js +166 -14
- package/cjs/liveGuideAdmission.d.ts +3 -2
- package/cjs/liveGuideAdmission.js +10 -2
- package/cjs/liveGuideWidget.d.ts +18 -0
- package/cjs/liveGuideWidget.js +228 -23
- package/cjs/locales/resources.js +2240 -0
- package/cjs/messages.js +56 -0
- package/cjs/tabLock.d.ts +2 -0
- package/cjs/tabLock.js +11 -1
- package/cjs/types.d.ts +6 -2
- package/cjs/types.js +56 -0
- package/cjs/ui.d.ts +37 -0
- package/cjs/ui.js +261 -9
- package/cjs/version.d.ts +1 -1
- package/cjs/version.js +1 -1
- package/lib/AiLiveAssist.d.ts +8 -1
- package/lib/AiLiveAssist.js +113 -8
- package/lib/client.d.ts +5 -3
- package/lib/client.js +44 -5
- package/lib/commerce/cartContracts.d.ts +158 -0
- package/lib/commerce/cartContracts.js +221 -0
- package/lib/commerce/cartSession.d.ts +86 -0
- package/lib/commerce/cartSession.js +471 -0
- package/lib/commerce/contracts.d.ts +152 -0
- package/lib/commerce/contracts.js +300 -0
- package/lib/commerce/pageContext.d.ts +50 -0
- package/lib/commerce/pageContext.js +168 -0
- package/lib/commerce/productPanel.d.ts +65 -0
- package/lib/commerce/productPanel.js +657 -0
- package/lib/commerce/realtimeCommerce.d.ts +73 -0
- package/lib/commerce/realtimeCommerce.js +337 -0
- package/lib/commerce/shopifyCart.d.ts +130 -0
- package/lib/commerce/shopifyCart.js +1130 -0
- package/lib/commerce/shopifyCartPresentation.d.ts +12 -0
- package/lib/commerce/shopifyCartPresentation.js +376 -0
- package/lib/commerce/shoppingNotes.d.ts +61 -0
- package/lib/commerce/shoppingNotes.js +307 -0
- package/lib/commerce/shoppingNotesView.d.ts +46 -0
- package/lib/commerce/shoppingNotesView.js +265 -0
- package/lib/control.d.ts +9 -1
- package/lib/control.js +51 -1
- package/lib/guideAdmission.d.ts +5 -2
- package/lib/guideAdmission.js +21 -2
- package/lib/guideInstaller.js +1 -1
- package/lib/guideMeasurement.d.ts +5 -0
- package/lib/guideMeasurement.js +24 -0
- package/lib/guideSubjectStore.js +2 -0
- package/lib/guideTypes.d.ts +18 -0
- package/lib/liveControlChannel.d.ts +43 -1
- package/lib/liveControlChannel.js +166 -14
- package/lib/liveGuideAdmission.d.ts +3 -2
- package/lib/liveGuideAdmission.js +10 -2
- package/lib/liveGuideWidget.d.ts +18 -0
- package/lib/liveGuideWidget.js +228 -23
- package/lib/locales/resources.js +2240 -0
- package/lib/messages.js +56 -0
- package/lib/tabLock.d.ts +2 -0
- package/lib/tabLock.js +11 -1
- package/lib/types.d.ts +6 -2
- package/lib/types.js +56 -0
- package/lib/ui.d.ts +37 -0
- package/lib/ui.js +261 -9
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +1 -1
package/cjs/ui.js
CHANGED
|
@@ -4,7 +4,11 @@ exports.WidgetView = void 0;
|
|
|
4
4
|
const lucide_1 = require("lucide");
|
|
5
5
|
const avatarUrl_js_1 = require("./avatarUrl.js");
|
|
6
6
|
const dialogFocusScope_js_1 = require("./dialogFocusScope.js");
|
|
7
|
+
const shoppingNotes_js_1 = require("./commerce/shoppingNotes.js");
|
|
8
|
+
const shoppingNotesView_js_1 = require("./commerce/shoppingNotesView.js");
|
|
7
9
|
const ctaOffer_js_1 = require("./ctaOffer.js");
|
|
10
|
+
const productPanel_js_1 = require("./commerce/productPanel.js");
|
|
11
|
+
const contracts_js_1 = require("./commerce/contracts.js");
|
|
8
12
|
const index_js_1 = require("./locales/index.js");
|
|
9
13
|
const PANEL_POSITION_KEY = "__oxvo_ai_live_assist_compact_voice_position_v2";
|
|
10
14
|
const LEGACY_PANEL_POSITION_KEY = "__oxvo_ai_live_assist_panel_position_v1";
|
|
@@ -4325,6 +4329,9 @@ const style = `
|
|
|
4325
4329
|
class WidgetView {
|
|
4326
4330
|
constructor(config, overrides, callbacks, options = {}) {
|
|
4327
4331
|
this.callbacks = callbacks;
|
|
4332
|
+
this.shoppingNotes = null;
|
|
4333
|
+
this.commercePanel = null;
|
|
4334
|
+
this.commerceCartStatus = null;
|
|
4328
4335
|
this.ctaCard = null;
|
|
4329
4336
|
this.ctaSlot = null;
|
|
4330
4337
|
this.ambient = null;
|
|
@@ -4337,6 +4344,7 @@ class WidgetView {
|
|
|
4337
4344
|
this.playbackAttempt = 0;
|
|
4338
4345
|
this.destroyed = false;
|
|
4339
4346
|
this.recordingConsent = false;
|
|
4347
|
+
this.commerceCartConsent = false;
|
|
4340
4348
|
this.mediaPlaybackActive = false;
|
|
4341
4349
|
this.remoteAudioContext = null;
|
|
4342
4350
|
this.remoteAudioContextStateListener = null;
|
|
@@ -4844,12 +4852,18 @@ class WidgetView {
|
|
|
4844
4852
|
this.manualTurnsSupported = options.manualTurnsSupported === true;
|
|
4845
4853
|
this.semanticStatus = this.messages.ready;
|
|
4846
4854
|
this.host = document.createElement("div");
|
|
4855
|
+
// The shadow host is empty in light DOM; keep storefront :empty rules from hiding it.
|
|
4856
|
+
this.host.style.setProperty("display", "block", "important");
|
|
4847
4857
|
this.host.dataset.oxvoAiLiveAssistRoot = "true";
|
|
4848
4858
|
this.host.dataset.activity = this.activity;
|
|
4849
4859
|
this.host.setAttribute("aria-live", "off");
|
|
4850
4860
|
this.shadow = this.host.attachShadow({ mode: "closed" });
|
|
4851
4861
|
const sheet = document.createElement("style");
|
|
4852
|
-
sheet.textContent = style + ctaOffer_js_1.CTA_OFFER_STYLES
|
|
4862
|
+
sheet.textContent = style + ctaOffer_js_1.CTA_OFFER_STYLES + productPanel_js_1.COMMERCE_PRODUCT_PANEL_STYLES + shoppingNotesView_js_1.SHOPPING_NOTES_STYLES + `
|
|
4863
|
+
.panel:not(.compact) .conversation.commerce-active { display: flex; flex-direction: column; gap: 8px; min-height: 0; }
|
|
4864
|
+
.commerce-slot { flex: 0 1 auto; min-height: 0; max-height: min(55dvh, 420px); overflow: auto; overscroll-behavior: contain; }
|
|
4865
|
+
.panel:not(.compact) .conversation.commerce-active .captions { flex: 1 1 80px; height: auto; min-height: 64px; }
|
|
4866
|
+
`;
|
|
4853
4867
|
this.shadow.append(sheet);
|
|
4854
4868
|
this.shadow.append(this.build());
|
|
4855
4869
|
document.documentElement.append(this.host);
|
|
@@ -5677,6 +5691,171 @@ class WidgetView {
|
|
|
5677
5691
|
message(key) {
|
|
5678
5692
|
return this.messages[key];
|
|
5679
5693
|
}
|
|
5694
|
+
setCommerceCatalog(catalog, callbacks) {
|
|
5695
|
+
this.clearCommerceCatalog();
|
|
5696
|
+
if (this.destroyed)
|
|
5697
|
+
return;
|
|
5698
|
+
const notes = this.shoppingNotes;
|
|
5699
|
+
const notesMatch = notes && catalog.guideId === notes.scope.guideId &&
|
|
5700
|
+
(0, contracts_js_1.sameCommerceStore)(catalog.store, notes.scope.store);
|
|
5701
|
+
const panel = new productPanel_js_1.CommerceProductPanel(key => this.message(key), {
|
|
5702
|
+
...callbacks,
|
|
5703
|
+
...(notesMatch ? { onShoppingNotes: () => { if (notes === this.shoppingNotes)
|
|
5704
|
+
this.openShoppingNotes(); },
|
|
5705
|
+
onSaveItem: (product) => { if (notes === this.shoppingNotes)
|
|
5706
|
+
this.openShoppingNotes(product); } } : {}),
|
|
5707
|
+
});
|
|
5708
|
+
this.commercePanel = panel;
|
|
5709
|
+
panel.element.classList.add("commerce-slot");
|
|
5710
|
+
this.conversation.classList.add("commerce-active");
|
|
5711
|
+
this.conversation.prepend(panel.element);
|
|
5712
|
+
panel.setCatalog(catalog);
|
|
5713
|
+
if (this.active && this.panel.classList.contains("open"))
|
|
5714
|
+
this.setCompact(false);
|
|
5715
|
+
requestAnimationFrame(() => { if (this.commercePanel === panel)
|
|
5716
|
+
panel.refreshVisibility(); });
|
|
5717
|
+
}
|
|
5718
|
+
clearCommerceCatalog() {
|
|
5719
|
+
this.commercePanel?.destroy();
|
|
5720
|
+
this.commercePanel = null;
|
|
5721
|
+
this.conversation?.classList.toggle("commerce-active", this.commerceCartStatus !== null);
|
|
5722
|
+
}
|
|
5723
|
+
configureShoppingNotes() {
|
|
5724
|
+
const scope = this.config.capabilities?.text === true ? (0, shoppingNotes_js_1.createShoppingNotesScope)(this.config) : null;
|
|
5725
|
+
if (JSON.stringify(scope) !== JSON.stringify(this.shoppingNotes?.scope ?? null)) {
|
|
5726
|
+
this.shoppingNotes?.destroy();
|
|
5727
|
+
this.shoppingNotes = scope ? new shoppingNotesView_js_1.ShoppingNotesView(scope, key => this.message(key), this.dialogFocus, {
|
|
5728
|
+
active: () => this.active || this.endRequested || this.stagedLaunchMode !== null,
|
|
5729
|
+
start: question => this.start("text", question),
|
|
5730
|
+
changed: () => this.syncShoppingNotesEntry(),
|
|
5731
|
+
fallbackFocus: () => this.active ? this.dialogFallbackFocus() : this.require('[data-role="intro-text-input"]'),
|
|
5732
|
+
}) : null;
|
|
5733
|
+
if (this.shoppingNotes)
|
|
5734
|
+
this.shadow.append(this.shoppingNotes.element);
|
|
5735
|
+
}
|
|
5736
|
+
this.syncShoppingNotesEntry();
|
|
5737
|
+
}
|
|
5738
|
+
syncShoppingNotesEntry() {
|
|
5739
|
+
const button = this.shadow.querySelector('[data-role="shopping-notes-entry"]');
|
|
5740
|
+
if (!button)
|
|
5741
|
+
return;
|
|
5742
|
+
button.textContent = this.messages.shoppingNotesReview;
|
|
5743
|
+
button.hidden = this.active || !this.shoppingNotes?.hasSaved();
|
|
5744
|
+
}
|
|
5745
|
+
openShoppingNotes(product) {
|
|
5746
|
+
if (this.destroyed || this.currentConfirmation || this.currentVisualRequest ||
|
|
5747
|
+
this.currentHandoffContextRequest || this.currentPageAssistanceRequest ||
|
|
5748
|
+
!this.require('[data-role="legal-overlay"]').hidden)
|
|
5749
|
+
return;
|
|
5750
|
+
this.releaseActivePushToTalk();
|
|
5751
|
+
this.shoppingNotes?.open(product);
|
|
5752
|
+
}
|
|
5753
|
+
setCommerceBusy(busy) { this.commercePanel?.setBusy(busy); }
|
|
5754
|
+
setCommerceError() { this.commercePanel?.showError(); }
|
|
5755
|
+
setCommerceCartActionHandler(handler, canAdd) {
|
|
5756
|
+
this.commercePanel?.setCartActionHandler(handler, canAdd);
|
|
5757
|
+
}
|
|
5758
|
+
showCommerceCartConfirmation(value, onDecision) {
|
|
5759
|
+
if (this.destroyed || !this.active) {
|
|
5760
|
+
onDecision(false);
|
|
5761
|
+
return;
|
|
5762
|
+
}
|
|
5763
|
+
const price = (0, productPanel_js_1.formatCommercePrice)(value.unitPrice.amount, value.unitPrice.currency, value.market.locale);
|
|
5764
|
+
const quantity = new Intl.NumberFormat(value.market.locale).format(value.quantity);
|
|
5765
|
+
this.showConfirmation({ actionId: value.operationId, proposalChecksum: value.proposalChecksum,
|
|
5766
|
+
action: this.messages.commerceAdd, targetLabel: value.title,
|
|
5767
|
+
reason: value.selectedOptions.map(option => `${option.name}: ${option.value}`).join(" · "),
|
|
5768
|
+
expectedEffect: `${quantity} × ${price} · ${new URL(value.store.origin).hostname}`,
|
|
5769
|
+
expiresAt: value.expiresAt, onDecision });
|
|
5770
|
+
}
|
|
5771
|
+
clearCommerceCartConfirmation(operationId) {
|
|
5772
|
+
const current = this.currentConfirmation;
|
|
5773
|
+
if (current?.onDecision && (!operationId || current.actionId === operationId))
|
|
5774
|
+
this.resolveConfirmation(false);
|
|
5775
|
+
}
|
|
5776
|
+
setCommerceCartStatus(outcome, cartUrl, onCheck) {
|
|
5777
|
+
this.clearCommerceCartStatus();
|
|
5778
|
+
if (this.destroyed || !this.active)
|
|
5779
|
+
return;
|
|
5780
|
+
if (this.semanticStatus === this.messages.commerceCartChecking && !this.currentConfirmation &&
|
|
5781
|
+
!this.currentVisualRequest && !this.currentHandoffContextRequest && !this.currentPageAssistanceRequest) {
|
|
5782
|
+
this.setStatus(this.muted && this.voiceActive ? this.messages.muted : this.assistantPresentationMessage());
|
|
5783
|
+
this.setActivity(this.assistantPresentationState());
|
|
5784
|
+
}
|
|
5785
|
+
const status = document.createElement("section");
|
|
5786
|
+
status.className = "commerce-panel commerce-slot commerce-cart-status";
|
|
5787
|
+
status.setAttribute("role", "status");
|
|
5788
|
+
status.setAttribute("aria-live", "polite");
|
|
5789
|
+
const summary = document.createElement("p");
|
|
5790
|
+
const key = outcome.status === "confirmed" && outcome.receipt
|
|
5791
|
+
? "commerceCartAdded" : outcome.status === "partial" && outcome.receipt ? "commerceCartPartial"
|
|
5792
|
+
: outcome.status === "conflict" ? "commerceCartChanged" : outcome.status === "unavailable"
|
|
5793
|
+
? "commerceCartUnavailable" : "commerceCartUncertain";
|
|
5794
|
+
summary.textContent = this.messages[key];
|
|
5795
|
+
status.append(summary);
|
|
5796
|
+
if (outcome.local.itemCount !== null && Number.isSafeInteger(outcome.local.itemCount) && outcome.local.itemCount >= 0) {
|
|
5797
|
+
const count = document.createElement("p");
|
|
5798
|
+
count.className = "commerce-product-note";
|
|
5799
|
+
count.textContent = this.messages.commerceCartCount.replace("{count}", new Intl.NumberFormat(this.host.lang || "en").format(outcome.local.itemCount));
|
|
5800
|
+
status.append(count);
|
|
5801
|
+
}
|
|
5802
|
+
const actions = document.createElement("div");
|
|
5803
|
+
actions.className = "commerce-panel-actions";
|
|
5804
|
+
if (onCheck && (outcome.status === "uncertain" ||
|
|
5805
|
+
((outcome.status === "confirmed" || outcome.status === "partial") && outcome.receipt))) {
|
|
5806
|
+
const check = document.createElement("button");
|
|
5807
|
+
check.type = "button";
|
|
5808
|
+
check.textContent = this.messages.commerceCartRecheck;
|
|
5809
|
+
check.addEventListener("click", async () => {
|
|
5810
|
+
if (check.disabled || this.destroyed || !this.active || this.commerceCartStatus !== status)
|
|
5811
|
+
return;
|
|
5812
|
+
check.disabled = true;
|
|
5813
|
+
check.setAttribute("aria-busy", "true");
|
|
5814
|
+
try {
|
|
5815
|
+
await onCheck();
|
|
5816
|
+
}
|
|
5817
|
+
catch { /* Keep the uncertain result available for another read-only check. */ }
|
|
5818
|
+
finally {
|
|
5819
|
+
if (this.commerceCartStatus === status && check.isConnected && !this.destroyed && this.active) {
|
|
5820
|
+
check.disabled = false;
|
|
5821
|
+
check.removeAttribute("aria-busy");
|
|
5822
|
+
}
|
|
5823
|
+
}
|
|
5824
|
+
});
|
|
5825
|
+
actions.append(check);
|
|
5826
|
+
}
|
|
5827
|
+
try {
|
|
5828
|
+
const url = new URL(cartUrl);
|
|
5829
|
+
if (url.protocol === "https:" && url.origin === window.location.origin && !url.username && !url.password &&
|
|
5830
|
+
/^\/(?:[a-z]{2,3}(?:-[a-z0-9]{2,8})*\/)?cart\/?$/iu.test(url.pathname) && !url.search && !url.hash) {
|
|
5831
|
+
const view = document.createElement("a");
|
|
5832
|
+
view.className = "commerce-product-link";
|
|
5833
|
+
view.href = url.href;
|
|
5834
|
+
view.textContent = this.messages.commerceViewCart;
|
|
5835
|
+
actions.append(view);
|
|
5836
|
+
}
|
|
5837
|
+
}
|
|
5838
|
+
catch { /* An invalid destination must not become a shopper link. */ }
|
|
5839
|
+
const keep = document.createElement("button");
|
|
5840
|
+
keep.type = "button";
|
|
5841
|
+
keep.textContent = this.messages.commerceKeepShopping;
|
|
5842
|
+
keep.addEventListener("click", () => {
|
|
5843
|
+
this.clearCommerceCartStatus();
|
|
5844
|
+
this.dialogFallbackFocus()?.focus();
|
|
5845
|
+
});
|
|
5846
|
+
actions.append(keep);
|
|
5847
|
+
status.append(actions);
|
|
5848
|
+
this.commerceCartStatus = status;
|
|
5849
|
+
this.conversation.prepend(status);
|
|
5850
|
+
this.conversation.classList.add("commerce-active");
|
|
5851
|
+
this.setCompact(false);
|
|
5852
|
+
this.openPanel();
|
|
5853
|
+
}
|
|
5854
|
+
clearCommerceCartStatus() {
|
|
5855
|
+
this.commerceCartStatus?.remove();
|
|
5856
|
+
this.commerceCartStatus = null;
|
|
5857
|
+
this.conversation?.classList.toggle("commerce-active", this.commercePanel !== null);
|
|
5858
|
+
}
|
|
5680
5859
|
setAdvancedSessionControlsVisible(visible) {
|
|
5681
5860
|
this.advancedSessionControlsVisible = visible;
|
|
5682
5861
|
this.syncAdvancedSessionControlsVisibility();
|
|
@@ -5720,6 +5899,7 @@ class WidgetView {
|
|
|
5720
5899
|
return this.start(mode);
|
|
5721
5900
|
}
|
|
5722
5901
|
close() {
|
|
5902
|
+
this.shoppingNotes?.close(false);
|
|
5723
5903
|
if (this.panel.classList.contains("open"))
|
|
5724
5904
|
this.closePanel();
|
|
5725
5905
|
}
|
|
@@ -6181,7 +6361,7 @@ class WidgetView {
|
|
|
6181
6361
|
return;
|
|
6182
6362
|
}
|
|
6183
6363
|
this.captions.querySelector('[data-role="empty"]')?.remove();
|
|
6184
|
-
const safe = text.slice(0, 16000);
|
|
6364
|
+
const safe = (role === "user" ? this.shoppingNotes?.captionText(text) ?? text : text).slice(0, 16000);
|
|
6185
6365
|
if (role === "assistant" && safe && !restored) {
|
|
6186
6366
|
this.assistantCaptionPhase = final ? "final" : "partial";
|
|
6187
6367
|
}
|
|
@@ -6755,7 +6935,8 @@ class WidgetView {
|
|
|
6755
6935
|
showConfirmation(value) {
|
|
6756
6936
|
this.dismissHandoffRequestPreparing();
|
|
6757
6937
|
if (this.currentConfirmation?.actionId === value.actionId &&
|
|
6758
|
-
this.currentConfirmation.proposalChecksum === value.proposalChecksum
|
|
6938
|
+
this.currentConfirmation.proposalChecksum === value.proposalChecksum &&
|
|
6939
|
+
Boolean(this.currentConfirmation.onDecision) === Boolean(value.onDecision)) {
|
|
6759
6940
|
return;
|
|
6760
6941
|
}
|
|
6761
6942
|
if (this.currentPageAssistanceRequest) {
|
|
@@ -6785,6 +6966,7 @@ class WidgetView {
|
|
|
6785
6966
|
this.setAmbientActive(true);
|
|
6786
6967
|
this.syncHeaderActions();
|
|
6787
6968
|
this.confirmation.scrollIntoView({ block: "nearest" });
|
|
6969
|
+
this.shoppingNotes?.close(false);
|
|
6788
6970
|
this.dialogFocus.present({
|
|
6789
6971
|
surface: this.confirmation,
|
|
6790
6972
|
initialFocus: () => this.require('[data-role="decline"]'),
|
|
@@ -7045,6 +7227,7 @@ class WidgetView {
|
|
|
7045
7227
|
this.syncPageAssistanceFooter();
|
|
7046
7228
|
const overlay = this.syncPageAssistancePresentation();
|
|
7047
7229
|
this.syncHeaderActions();
|
|
7230
|
+
this.shoppingNotes?.close(false);
|
|
7048
7231
|
this.dialogFocus.present({
|
|
7049
7232
|
surface: overlay,
|
|
7050
7233
|
initialFocus: () => this.require('[data-role="page-assistance-decline"]'),
|
|
@@ -7663,6 +7846,8 @@ class WidgetView {
|
|
|
7663
7846
|
true;
|
|
7664
7847
|
}
|
|
7665
7848
|
showError(message, retryable = false, sessionActive = this.active) {
|
|
7849
|
+
if (this.stagedLaunchMode !== null || this.assistantState === "connecting")
|
|
7850
|
+
this.shoppingNotes?.markLaunchFailed();
|
|
7666
7851
|
this.setActionStateRunning(false);
|
|
7667
7852
|
if (this.voiceActive || this.audio.srcObject) {
|
|
7668
7853
|
this.pauseRemotePlayback(true);
|
|
@@ -7719,6 +7904,8 @@ class WidgetView {
|
|
|
7719
7904
|
]);
|
|
7720
7905
|
}
|
|
7721
7906
|
showEndingDetached(message) {
|
|
7907
|
+
this.clearCommerceCartStatus();
|
|
7908
|
+
this.clearCommerceCartConfirmation();
|
|
7722
7909
|
const continuingEndingPresentation = this.panel.classList.contains("ending-state");
|
|
7723
7910
|
if (!continuingEndingPresentation) {
|
|
7724
7911
|
this.endingPresentationDismissed = false;
|
|
@@ -7736,6 +7923,7 @@ class WidgetView {
|
|
|
7736
7923
|
this.currentConfirmation = null;
|
|
7737
7924
|
this.currentVisualRequest = null;
|
|
7738
7925
|
this.currentHandoffContextRequest = null;
|
|
7926
|
+
this.shoppingNotes?.close(false);
|
|
7739
7927
|
this.dialogFocus.clear({ restore: false });
|
|
7740
7928
|
this.assistantCaptionPhase = "none";
|
|
7741
7929
|
this.clearPendingCaptions();
|
|
@@ -7795,6 +7983,7 @@ class WidgetView {
|
|
|
7795
7983
|
this.currentConfirmation = null;
|
|
7796
7984
|
this.currentVisualRequest = null;
|
|
7797
7985
|
this.currentHandoffContextRequest = null;
|
|
7986
|
+
this.shoppingNotes?.close(false);
|
|
7798
7987
|
this.dialogFocus.clear({ restore: false });
|
|
7799
7988
|
this.assistantCaptionPhase = "none";
|
|
7800
7989
|
this.clearPendingCaptions();
|
|
@@ -7833,6 +8022,10 @@ class WidgetView {
|
|
|
7833
8022
|
this.clearIntroTransition();
|
|
7834
8023
|
this.introMinimized = false;
|
|
7835
8024
|
this.syncIntroMinimizedState();
|
|
8025
|
+
if (this.shoppingNotes?.retry(question, message)) {
|
|
8026
|
+
this.setStatus(message);
|
|
8027
|
+
return;
|
|
8028
|
+
}
|
|
7836
8029
|
const input = this.require('[data-role="intro-text-input"]');
|
|
7837
8030
|
input.value = question.slice(0, INITIAL_QUESTION_MAX_LENGTH);
|
|
7838
8031
|
input.setAttribute("aria-invalid", "false");
|
|
@@ -7888,6 +8081,7 @@ class WidgetView {
|
|
|
7888
8081
|
this.currentConfirmation = null;
|
|
7889
8082
|
this.currentVisualRequest = null;
|
|
7890
8083
|
this.currentHandoffContextRequest = null;
|
|
8084
|
+
this.shoppingNotes?.close(false);
|
|
7891
8085
|
this.dialogFocus.clear({ restore: false });
|
|
7892
8086
|
if (this.muted)
|
|
7893
8087
|
this.setMuted(false);
|
|
@@ -8231,6 +8425,11 @@ class WidgetView {
|
|
|
8231
8425
|
});
|
|
8232
8426
|
}
|
|
8233
8427
|
destroy() {
|
|
8428
|
+
this.shoppingNotes?.destroy();
|
|
8429
|
+
this.shoppingNotes = null;
|
|
8430
|
+
this.clearCommerceCartConfirmation();
|
|
8431
|
+
this.clearCommerceCatalog();
|
|
8432
|
+
this.clearCommerceCartStatus();
|
|
8234
8433
|
this.clearCtaOffer();
|
|
8235
8434
|
if (this.destroyed)
|
|
8236
8435
|
return;
|
|
@@ -8306,7 +8505,9 @@ class WidgetView {
|
|
|
8306
8505
|
<div class="status-card" data-role="availability" role="status" tabindex="-1"></div>
|
|
8307
8506
|
<div class="status-card" data-role="elsewhere" role="status" tabindex="-1"></div>
|
|
8308
8507
|
<div class="intro-entry" data-role="intro-entry" data-has-draft="false" aria-busy="false" hidden>
|
|
8508
|
+
<button type="button" class="shopping-notes-entry" data-role="shopping-notes-entry" hidden></button>
|
|
8309
8509
|
<label class="recording-consent" data-role="recording-consent" hidden><input type="checkbox" data-role="recording-consent-input"><span><strong data-role="recording-consent-label"></strong><small data-role="recording-consent-description"></small></span></label>
|
|
8510
|
+
<label class="recording-consent commerce-cart-consent" data-role="commerce-cart-consent" hidden><input type="checkbox" data-role="commerce-cart-consent-input"><span><strong data-role="commerce-cart-consent-label"></strong><small data-role="commerce-cart-consent-description"></small></span></label>
|
|
8310
8511
|
<div class="proactive-engagement" data-role="proactive-engagement" hidden>
|
|
8311
8512
|
<div class="proactive-rail" data-role="proactive-prompts" role="group"></div>
|
|
8312
8513
|
</div>
|
|
@@ -8394,6 +8595,7 @@ class WidgetView {
|
|
|
8394
8595
|
<div class="boundary" data-role="boundary"></div>
|
|
8395
8596
|
<ul data-role="legal-scopes"></ul>
|
|
8396
8597
|
<label class="recording-consent" data-role="recording-consent" hidden><input type="checkbox" data-role="recording-consent-input"><span><strong data-role="recording-consent-label"></strong><small data-role="recording-consent-description"></small></span></label>
|
|
8598
|
+
<label class="recording-consent commerce-cart-consent" data-role="commerce-cart-consent" hidden><input type="checkbox" data-role="commerce-cart-consent-input"><span><strong data-role="commerce-cart-consent-label"></strong><small data-role="commerce-cart-consent-description"></small></span></label>
|
|
8397
8599
|
<div class="legal-links" data-role="legal-links"><a data-role="legal-privacy" target="_blank" rel="noopener noreferrer"></a><a data-role="legal-terms" target="_blank" rel="noopener noreferrer"></a></div>
|
|
8398
8600
|
<button type="button" class="secondary legal-revoke" data-role="page-assistance-revoke" hidden><span class="menu-icon" data-icon aria-hidden="true"></span><span class="control-label"></span></button>
|
|
8399
8601
|
</section>
|
|
@@ -8504,6 +8706,7 @@ class WidgetView {
|
|
|
8504
8706
|
return fragment;
|
|
8505
8707
|
}
|
|
8506
8708
|
bind() {
|
|
8709
|
+
this.require('[data-role="shopping-notes-entry"]').addEventListener("click", () => this.openShoppingNotes());
|
|
8507
8710
|
this.panel.addEventListener("pointerdown", this.onPlaybackActivation, true);
|
|
8508
8711
|
this.panel.addEventListener("wheel", this.onPanelWheel, { passive: false });
|
|
8509
8712
|
this.captions.addEventListener("scroll", this.onCaptionsScroll, {
|
|
@@ -8872,6 +9075,7 @@ class WidgetView {
|
|
|
8872
9075
|
window.visualViewport?.addEventListener("scroll", this.onHighlightViewportGeometryChange, { passive: true });
|
|
8873
9076
|
}
|
|
8874
9077
|
applyConfig() {
|
|
9078
|
+
this.configureShoppingNotes();
|
|
8875
9079
|
const appearance = this.config.appearance;
|
|
8876
9080
|
const anchor = appearance?.position === "left" || appearance?.position === "center"
|
|
8877
9081
|
? appearance.position
|
|
@@ -9106,6 +9310,7 @@ class WidgetView {
|
|
|
9106
9310
|
this.messages.notResolved;
|
|
9107
9311
|
this.renderLegalScopes();
|
|
9108
9312
|
this.renderRecordingConsent();
|
|
9313
|
+
this.renderCommerceCartConsent();
|
|
9109
9314
|
const privacy = this.require('[data-role="privacy"]');
|
|
9110
9315
|
if (this.config.consent?.policyUrl)
|
|
9111
9316
|
privacy.href = this.config.consent.policyUrl;
|
|
@@ -9192,6 +9397,28 @@ class WidgetView {
|
|
|
9192
9397
|
};
|
|
9193
9398
|
}
|
|
9194
9399
|
}
|
|
9400
|
+
commerceCartConsentOffered() {
|
|
9401
|
+
return this.config.schemaVersion === 3 && this.config.capabilities?.commerceCart === true &&
|
|
9402
|
+
this.config.consent?.optionalScopes.includes("commerce_cart") === true &&
|
|
9403
|
+
(0, contracts_js_1.parseCommerceBootstrap)(this.config.commerce, this.config.guideId, location.origin)?.cartEnabled === true;
|
|
9404
|
+
}
|
|
9405
|
+
renderCommerceCartConsent() {
|
|
9406
|
+
const offered = this.commerceCartConsentOffered();
|
|
9407
|
+
for (const row of this.shadow.querySelectorAll('[data-role="commerce-cart-consent"]')) {
|
|
9408
|
+
row.hidden = !offered || (this.introMinimized && row.closest('[data-role="intro-entry"]') !== null);
|
|
9409
|
+
row.querySelector('[data-role="commerce-cart-consent-label"]').textContent = this.messages.commerceCartConsent;
|
|
9410
|
+
row.querySelector('[data-role="commerce-cart-consent-description"]').textContent = this.messages.commerceCartConsentDescription;
|
|
9411
|
+
const input = row.querySelector('[data-role="commerce-cart-consent-input"]');
|
|
9412
|
+
input.checked = offered && this.commerceCartConsent;
|
|
9413
|
+
input.disabled = this.active || this.endRequested;
|
|
9414
|
+
input.onchange = () => {
|
|
9415
|
+
if (!this.destroyed && !this.active && !this.endRequested && this.commerceCartConsentOffered()) {
|
|
9416
|
+
this.commerceCartConsent = input.checked;
|
|
9417
|
+
}
|
|
9418
|
+
this.renderCommerceCartConsent();
|
|
9419
|
+
};
|
|
9420
|
+
}
|
|
9421
|
+
}
|
|
9195
9422
|
renderLegalScopes() {
|
|
9196
9423
|
const container = this.require('[data-role="legal-scopes"]');
|
|
9197
9424
|
container.replaceChildren();
|
|
@@ -9203,6 +9430,7 @@ class WidgetView {
|
|
|
9203
9430
|
microphone: "microphoneConsent",
|
|
9204
9431
|
page_context: "pageConsent",
|
|
9205
9432
|
browser_control: "controlConsent",
|
|
9433
|
+
commerce_cart: "commerceCartConsentDescription",
|
|
9206
9434
|
visual_context: "visualConsent",
|
|
9207
9435
|
handoff_context: "handoffConsent",
|
|
9208
9436
|
retained_transcript: "retentionConsent",
|
|
@@ -9211,6 +9439,7 @@ class WidgetView {
|
|
|
9211
9439
|
"microphone",
|
|
9212
9440
|
"page_context",
|
|
9213
9441
|
"browser_control",
|
|
9442
|
+
"commerce_cart",
|
|
9214
9443
|
"visual_context",
|
|
9215
9444
|
"handoff_context",
|
|
9216
9445
|
"retained_transcript",
|
|
@@ -9239,6 +9468,8 @@ class WidgetView {
|
|
|
9239
9468
|
const scopes = ["ai_disclosure", "text"];
|
|
9240
9469
|
if (this.recordingConsentOffered() && this.recordingConsent)
|
|
9241
9470
|
scopes.push("session_recording");
|
|
9471
|
+
if (this.commerceCartConsentOffered() && this.commerceCartConsent)
|
|
9472
|
+
scopes.push("commerce_cart");
|
|
9242
9473
|
if (required.has("page_context") &&
|
|
9243
9474
|
this.config.capabilities?.pageContext === true) {
|
|
9244
9475
|
scopes.push("page_context");
|
|
@@ -9256,6 +9487,7 @@ class WidgetView {
|
|
|
9256
9487
|
const shouldStageWelcome = mode === "text" && !initialQuestion && !this.welcomePresented;
|
|
9257
9488
|
if (shouldStageWelcome)
|
|
9258
9489
|
this.ensureWelcomeSkeleton();
|
|
9490
|
+
this.shoppingNotes?.prepareLaunch(initialQuestion);
|
|
9259
9491
|
const admitted = initialQuestion
|
|
9260
9492
|
? this.callbacks.onStart(mode, scopes, initialQuestion)
|
|
9261
9493
|
: this.callbacks.onStart(mode, scopes);
|
|
@@ -9388,6 +9620,7 @@ class WidgetView {
|
|
|
9388
9620
|
this.focusIntroControl(this.config.capabilities?.text === true ? "text" : "voice");
|
|
9389
9621
|
}
|
|
9390
9622
|
syncIntroMinimizedState() {
|
|
9623
|
+
this.renderCommerceCartConsent();
|
|
9391
9624
|
const entry = this.require('[data-role="intro-entry"]');
|
|
9392
9625
|
const frame = this.require('[data-role="intro-composer"]');
|
|
9393
9626
|
const composer = this.require(".intro-composer");
|
|
@@ -9531,12 +9764,18 @@ class WidgetView {
|
|
|
9531
9764
|
const value = this.currentConfirmation;
|
|
9532
9765
|
if (!value)
|
|
9533
9766
|
return false;
|
|
9534
|
-
if (Date.parse(value.expiresAt) <= Date.now()) {
|
|
9767
|
+
if (!Number.isFinite(Date.parse(value.expiresAt)) || Date.parse(value.expiresAt) <= Date.now()) {
|
|
9535
9768
|
this.confirmation.classList.remove("visible");
|
|
9536
9769
|
this.currentConfirmation = null;
|
|
9537
9770
|
this.dialogFocus.dismiss(this.confirmation);
|
|
9538
|
-
|
|
9539
|
-
|
|
9771
|
+
if (value.onDecision) {
|
|
9772
|
+
this.setStatus(this.muted && this.voiceActive ? this.messages.muted : this.assistantPresentationMessage());
|
|
9773
|
+
value.onDecision(false);
|
|
9774
|
+
}
|
|
9775
|
+
else {
|
|
9776
|
+
this.callbacks.onConfirmation(value.actionId, value.proposalChecksum, false);
|
|
9777
|
+
this.showActionState("failed");
|
|
9778
|
+
}
|
|
9540
9779
|
return true;
|
|
9541
9780
|
}
|
|
9542
9781
|
this.confirmation.classList.remove("visible");
|
|
@@ -9544,7 +9783,13 @@ class WidgetView {
|
|
|
9544
9783
|
this.dialogFocus.dismiss(this.confirmation);
|
|
9545
9784
|
this.restoreVoicePresenceAfterPrompt();
|
|
9546
9785
|
this.syncHeaderActions();
|
|
9547
|
-
|
|
9786
|
+
if (value.onDecision) {
|
|
9787
|
+
this.setStatus(approved ? this.messages.commerceCartChecking :
|
|
9788
|
+
this.muted && this.voiceActive ? this.messages.muted : this.assistantPresentationMessage());
|
|
9789
|
+
value.onDecision(approved);
|
|
9790
|
+
}
|
|
9791
|
+
else
|
|
9792
|
+
this.callbacks.onConfirmation(value.actionId, value.proposalChecksum, approved);
|
|
9548
9793
|
return true;
|
|
9549
9794
|
}
|
|
9550
9795
|
restoreVoicePresenceAfterPrompt() {
|
|
@@ -9794,6 +10039,7 @@ class WidgetView {
|
|
|
9794
10039
|
}
|
|
9795
10040
|
presentContextPermissionDialog() {
|
|
9796
10041
|
this.restoreContextPermissionDialogAttributes();
|
|
10042
|
+
this.shoppingNotes?.close(false);
|
|
9797
10043
|
this.dialogFocus.present({
|
|
9798
10044
|
surface: this.visualRequest,
|
|
9799
10045
|
initialFocus: () => this.require('[data-role="visual-decline"]'),
|
|
@@ -9835,7 +10081,7 @@ class WidgetView {
|
|
|
9835
10081
|
currentSafetyIdentity(kind) {
|
|
9836
10082
|
if (kind === "confirmation") {
|
|
9837
10083
|
const value = this.currentConfirmation;
|
|
9838
|
-
return value ? `${value.actionId}:${value.proposalChecksum}` : null;
|
|
10084
|
+
return value ? `${value.onDecision ? "commerce" : "action"}:${value.actionId}:${value.proposalChecksum}` : null;
|
|
9839
10085
|
}
|
|
9840
10086
|
if (this.currentHandoffContextRequest) {
|
|
9841
10087
|
return `handoff:${this.currentHandoffContextRequest.requestId}:${this.currentHandoffContextRequest.requestChecksum}`;
|
|
@@ -10146,11 +10392,12 @@ class WidgetView {
|
|
|
10146
10392
|
this.writePanelVisibility("open");
|
|
10147
10393
|
this.syncLauncherState();
|
|
10148
10394
|
this.syncHeaderActions();
|
|
10149
|
-
requestAnimationFrame(() => this.clampPanelPosition());
|
|
10395
|
+
requestAnimationFrame(() => { this.clampPanelPosition(); this.commercePanel?.refreshVisibility(); });
|
|
10150
10396
|
if (!wasOpen && notifyOpen)
|
|
10151
10397
|
this.callbacks.onOpenChange?.(true);
|
|
10152
10398
|
}
|
|
10153
10399
|
closePanel() {
|
|
10400
|
+
this.shoppingNotes?.close(false);
|
|
10154
10401
|
if (!this.panel.classList.contains("open"))
|
|
10155
10402
|
return;
|
|
10156
10403
|
if (this.panel.classList.contains("ending-state")) {
|
|
@@ -10299,6 +10546,7 @@ class WidgetView {
|
|
|
10299
10546
|
if (!value)
|
|
10300
10547
|
this.panel.classList.remove("compact-text-arrived");
|
|
10301
10548
|
this.panel.classList.toggle("compact", this.compact);
|
|
10549
|
+
requestAnimationFrame(() => this.commercePanel?.refreshVisibility());
|
|
10302
10550
|
this.placeCtaOffer();
|
|
10303
10551
|
this.syncSurfaceEffectOwner();
|
|
10304
10552
|
if (persist && this.active && this.persistentState) {
|
|
@@ -11005,6 +11253,7 @@ class WidgetView {
|
|
|
11005
11253
|
this.stagedLaunchMode = null;
|
|
11006
11254
|
this.initialQuestionStaged = false;
|
|
11007
11255
|
this.active = false;
|
|
11256
|
+
this.commerceCartConsent = false;
|
|
11008
11257
|
this.endRequested = false;
|
|
11009
11258
|
if (this.paused)
|
|
11010
11259
|
this.setPaused(false);
|
|
@@ -11091,6 +11340,7 @@ class WidgetView {
|
|
|
11091
11340
|
}
|
|
11092
11341
|
const overlay = this.require('[data-role="legal-overlay"]');
|
|
11093
11342
|
overlay.hidden = false;
|
|
11343
|
+
this.shoppingNotes?.close(false);
|
|
11094
11344
|
this.dialogFocus.present({
|
|
11095
11345
|
surface: overlay,
|
|
11096
11346
|
initialFocus: () => this.require('[data-role="legal-close"]'),
|
|
@@ -11387,6 +11637,8 @@ class WidgetView {
|
|
|
11387
11637
|
this.restorePanelPosition();
|
|
11388
11638
|
}
|
|
11389
11639
|
syncHeaderActions() {
|
|
11640
|
+
this.syncShoppingNotesEntry();
|
|
11641
|
+
this.renderCommerceCartConsent();
|
|
11390
11642
|
this.panel.classList.toggle("active-session", this.active);
|
|
11391
11643
|
this.syncSessionModeUi();
|
|
11392
11644
|
const errorState = this.panel.classList.contains("error-state");
|
package/cjs/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "7.5.
|
|
1
|
+
export declare const VERSION = "7.5.21";
|
package/cjs/version.js
CHANGED
package/lib/AiLiveAssist.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ export declare const normalizeAiGuideOpenInput: (input?: AiGuideOpenInput) => Re
|
|
|
34
34
|
export declare const resolveAiGuideProtocolVersion: (bootstrap: Pick<BootstrapConfig, "experienceMode" | "minimumProtocolVersion" | "protocol">) => 1 | 2;
|
|
35
35
|
export default class AiLiveAssist {
|
|
36
36
|
private readonly options;
|
|
37
|
-
readonly version = "7.5.
|
|
37
|
+
readonly version = "7.5.21";
|
|
38
38
|
private readonly host;
|
|
39
39
|
private readonly guideAdmission;
|
|
40
40
|
private readonly standaloneAdmissionPending;
|
|
@@ -127,6 +127,9 @@ export default class AiLiveAssist {
|
|
|
127
127
|
private channel;
|
|
128
128
|
private media;
|
|
129
129
|
private context;
|
|
130
|
+
private commerce;
|
|
131
|
+
private commerceReadyChannel;
|
|
132
|
+
private pendingCommerceGeneration;
|
|
130
133
|
private presentation;
|
|
131
134
|
private connectionAbort;
|
|
132
135
|
private connectionGeneration;
|
|
@@ -448,6 +451,9 @@ export default class AiLiveAssist {
|
|
|
448
451
|
private deliverContextNavigation;
|
|
449
452
|
private commitAuthorizedRuntimePath;
|
|
450
453
|
private waitForPendingContextNavigationAcknowledgements;
|
|
454
|
+
private commerceBootstrap;
|
|
455
|
+
private commerceCartEnabled;
|
|
456
|
+
private startRealtimeCommerce;
|
|
451
457
|
private startContext;
|
|
452
458
|
private startPresentation;
|
|
453
459
|
private sendText;
|
|
@@ -767,6 +773,7 @@ export default class AiLiveAssist {
|
|
|
767
773
|
private isVoicePresence;
|
|
768
774
|
private lowPowerMode;
|
|
769
775
|
private bindWindowLifecycle;
|
|
776
|
+
private handledPageHide;
|
|
770
777
|
private onPageHide;
|
|
771
778
|
private onPageShow;
|
|
772
779
|
private onWindowFocus;
|