@oxvo/ai-live-assist 7.5.20 → 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 +259 -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 +259 -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;
|
|
@@ -4851,7 +4859,11 @@ class WidgetView {
|
|
|
4851
4859
|
this.host.setAttribute("aria-live", "off");
|
|
4852
4860
|
this.shadow = this.host.attachShadow({ mode: "closed" });
|
|
4853
4861
|
const sheet = document.createElement("style");
|
|
4854
|
-
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
|
+
`;
|
|
4855
4867
|
this.shadow.append(sheet);
|
|
4856
4868
|
this.shadow.append(this.build());
|
|
4857
4869
|
document.documentElement.append(this.host);
|
|
@@ -5679,6 +5691,171 @@ class WidgetView {
|
|
|
5679
5691
|
message(key) {
|
|
5680
5692
|
return this.messages[key];
|
|
5681
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
|
+
}
|
|
5682
5859
|
setAdvancedSessionControlsVisible(visible) {
|
|
5683
5860
|
this.advancedSessionControlsVisible = visible;
|
|
5684
5861
|
this.syncAdvancedSessionControlsVisibility();
|
|
@@ -5722,6 +5899,7 @@ class WidgetView {
|
|
|
5722
5899
|
return this.start(mode);
|
|
5723
5900
|
}
|
|
5724
5901
|
close() {
|
|
5902
|
+
this.shoppingNotes?.close(false);
|
|
5725
5903
|
if (this.panel.classList.contains("open"))
|
|
5726
5904
|
this.closePanel();
|
|
5727
5905
|
}
|
|
@@ -6183,7 +6361,7 @@ class WidgetView {
|
|
|
6183
6361
|
return;
|
|
6184
6362
|
}
|
|
6185
6363
|
this.captions.querySelector('[data-role="empty"]')?.remove();
|
|
6186
|
-
const safe = text.slice(0, 16000);
|
|
6364
|
+
const safe = (role === "user" ? this.shoppingNotes?.captionText(text) ?? text : text).slice(0, 16000);
|
|
6187
6365
|
if (role === "assistant" && safe && !restored) {
|
|
6188
6366
|
this.assistantCaptionPhase = final ? "final" : "partial";
|
|
6189
6367
|
}
|
|
@@ -6757,7 +6935,8 @@ class WidgetView {
|
|
|
6757
6935
|
showConfirmation(value) {
|
|
6758
6936
|
this.dismissHandoffRequestPreparing();
|
|
6759
6937
|
if (this.currentConfirmation?.actionId === value.actionId &&
|
|
6760
|
-
this.currentConfirmation.proposalChecksum === value.proposalChecksum
|
|
6938
|
+
this.currentConfirmation.proposalChecksum === value.proposalChecksum &&
|
|
6939
|
+
Boolean(this.currentConfirmation.onDecision) === Boolean(value.onDecision)) {
|
|
6761
6940
|
return;
|
|
6762
6941
|
}
|
|
6763
6942
|
if (this.currentPageAssistanceRequest) {
|
|
@@ -6787,6 +6966,7 @@ class WidgetView {
|
|
|
6787
6966
|
this.setAmbientActive(true);
|
|
6788
6967
|
this.syncHeaderActions();
|
|
6789
6968
|
this.confirmation.scrollIntoView({ block: "nearest" });
|
|
6969
|
+
this.shoppingNotes?.close(false);
|
|
6790
6970
|
this.dialogFocus.present({
|
|
6791
6971
|
surface: this.confirmation,
|
|
6792
6972
|
initialFocus: () => this.require('[data-role="decline"]'),
|
|
@@ -7047,6 +7227,7 @@ class WidgetView {
|
|
|
7047
7227
|
this.syncPageAssistanceFooter();
|
|
7048
7228
|
const overlay = this.syncPageAssistancePresentation();
|
|
7049
7229
|
this.syncHeaderActions();
|
|
7230
|
+
this.shoppingNotes?.close(false);
|
|
7050
7231
|
this.dialogFocus.present({
|
|
7051
7232
|
surface: overlay,
|
|
7052
7233
|
initialFocus: () => this.require('[data-role="page-assistance-decline"]'),
|
|
@@ -7665,6 +7846,8 @@ class WidgetView {
|
|
|
7665
7846
|
true;
|
|
7666
7847
|
}
|
|
7667
7848
|
showError(message, retryable = false, sessionActive = this.active) {
|
|
7849
|
+
if (this.stagedLaunchMode !== null || this.assistantState === "connecting")
|
|
7850
|
+
this.shoppingNotes?.markLaunchFailed();
|
|
7668
7851
|
this.setActionStateRunning(false);
|
|
7669
7852
|
if (this.voiceActive || this.audio.srcObject) {
|
|
7670
7853
|
this.pauseRemotePlayback(true);
|
|
@@ -7721,6 +7904,8 @@ class WidgetView {
|
|
|
7721
7904
|
]);
|
|
7722
7905
|
}
|
|
7723
7906
|
showEndingDetached(message) {
|
|
7907
|
+
this.clearCommerceCartStatus();
|
|
7908
|
+
this.clearCommerceCartConfirmation();
|
|
7724
7909
|
const continuingEndingPresentation = this.panel.classList.contains("ending-state");
|
|
7725
7910
|
if (!continuingEndingPresentation) {
|
|
7726
7911
|
this.endingPresentationDismissed = false;
|
|
@@ -7738,6 +7923,7 @@ class WidgetView {
|
|
|
7738
7923
|
this.currentConfirmation = null;
|
|
7739
7924
|
this.currentVisualRequest = null;
|
|
7740
7925
|
this.currentHandoffContextRequest = null;
|
|
7926
|
+
this.shoppingNotes?.close(false);
|
|
7741
7927
|
this.dialogFocus.clear({ restore: false });
|
|
7742
7928
|
this.assistantCaptionPhase = "none";
|
|
7743
7929
|
this.clearPendingCaptions();
|
|
@@ -7797,6 +7983,7 @@ class WidgetView {
|
|
|
7797
7983
|
this.currentConfirmation = null;
|
|
7798
7984
|
this.currentVisualRequest = null;
|
|
7799
7985
|
this.currentHandoffContextRequest = null;
|
|
7986
|
+
this.shoppingNotes?.close(false);
|
|
7800
7987
|
this.dialogFocus.clear({ restore: false });
|
|
7801
7988
|
this.assistantCaptionPhase = "none";
|
|
7802
7989
|
this.clearPendingCaptions();
|
|
@@ -7835,6 +8022,10 @@ class WidgetView {
|
|
|
7835
8022
|
this.clearIntroTransition();
|
|
7836
8023
|
this.introMinimized = false;
|
|
7837
8024
|
this.syncIntroMinimizedState();
|
|
8025
|
+
if (this.shoppingNotes?.retry(question, message)) {
|
|
8026
|
+
this.setStatus(message);
|
|
8027
|
+
return;
|
|
8028
|
+
}
|
|
7838
8029
|
const input = this.require('[data-role="intro-text-input"]');
|
|
7839
8030
|
input.value = question.slice(0, INITIAL_QUESTION_MAX_LENGTH);
|
|
7840
8031
|
input.setAttribute("aria-invalid", "false");
|
|
@@ -7890,6 +8081,7 @@ class WidgetView {
|
|
|
7890
8081
|
this.currentConfirmation = null;
|
|
7891
8082
|
this.currentVisualRequest = null;
|
|
7892
8083
|
this.currentHandoffContextRequest = null;
|
|
8084
|
+
this.shoppingNotes?.close(false);
|
|
7893
8085
|
this.dialogFocus.clear({ restore: false });
|
|
7894
8086
|
if (this.muted)
|
|
7895
8087
|
this.setMuted(false);
|
|
@@ -8233,6 +8425,11 @@ class WidgetView {
|
|
|
8233
8425
|
});
|
|
8234
8426
|
}
|
|
8235
8427
|
destroy() {
|
|
8428
|
+
this.shoppingNotes?.destroy();
|
|
8429
|
+
this.shoppingNotes = null;
|
|
8430
|
+
this.clearCommerceCartConfirmation();
|
|
8431
|
+
this.clearCommerceCatalog();
|
|
8432
|
+
this.clearCommerceCartStatus();
|
|
8236
8433
|
this.clearCtaOffer();
|
|
8237
8434
|
if (this.destroyed)
|
|
8238
8435
|
return;
|
|
@@ -8308,7 +8505,9 @@ class WidgetView {
|
|
|
8308
8505
|
<div class="status-card" data-role="availability" role="status" tabindex="-1"></div>
|
|
8309
8506
|
<div class="status-card" data-role="elsewhere" role="status" tabindex="-1"></div>
|
|
8310
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>
|
|
8311
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>
|
|
8312
8511
|
<div class="proactive-engagement" data-role="proactive-engagement" hidden>
|
|
8313
8512
|
<div class="proactive-rail" data-role="proactive-prompts" role="group"></div>
|
|
8314
8513
|
</div>
|
|
@@ -8396,6 +8595,7 @@ class WidgetView {
|
|
|
8396
8595
|
<div class="boundary" data-role="boundary"></div>
|
|
8397
8596
|
<ul data-role="legal-scopes"></ul>
|
|
8398
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>
|
|
8399
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>
|
|
8400
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>
|
|
8401
8601
|
</section>
|
|
@@ -8506,6 +8706,7 @@ class WidgetView {
|
|
|
8506
8706
|
return fragment;
|
|
8507
8707
|
}
|
|
8508
8708
|
bind() {
|
|
8709
|
+
this.require('[data-role="shopping-notes-entry"]').addEventListener("click", () => this.openShoppingNotes());
|
|
8509
8710
|
this.panel.addEventListener("pointerdown", this.onPlaybackActivation, true);
|
|
8510
8711
|
this.panel.addEventListener("wheel", this.onPanelWheel, { passive: false });
|
|
8511
8712
|
this.captions.addEventListener("scroll", this.onCaptionsScroll, {
|
|
@@ -8874,6 +9075,7 @@ class WidgetView {
|
|
|
8874
9075
|
window.visualViewport?.addEventListener("scroll", this.onHighlightViewportGeometryChange, { passive: true });
|
|
8875
9076
|
}
|
|
8876
9077
|
applyConfig() {
|
|
9078
|
+
this.configureShoppingNotes();
|
|
8877
9079
|
const appearance = this.config.appearance;
|
|
8878
9080
|
const anchor = appearance?.position === "left" || appearance?.position === "center"
|
|
8879
9081
|
? appearance.position
|
|
@@ -9108,6 +9310,7 @@ class WidgetView {
|
|
|
9108
9310
|
this.messages.notResolved;
|
|
9109
9311
|
this.renderLegalScopes();
|
|
9110
9312
|
this.renderRecordingConsent();
|
|
9313
|
+
this.renderCommerceCartConsent();
|
|
9111
9314
|
const privacy = this.require('[data-role="privacy"]');
|
|
9112
9315
|
if (this.config.consent?.policyUrl)
|
|
9113
9316
|
privacy.href = this.config.consent.policyUrl;
|
|
@@ -9194,6 +9397,28 @@ class WidgetView {
|
|
|
9194
9397
|
};
|
|
9195
9398
|
}
|
|
9196
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
|
+
}
|
|
9197
9422
|
renderLegalScopes() {
|
|
9198
9423
|
const container = this.require('[data-role="legal-scopes"]');
|
|
9199
9424
|
container.replaceChildren();
|
|
@@ -9205,6 +9430,7 @@ class WidgetView {
|
|
|
9205
9430
|
microphone: "microphoneConsent",
|
|
9206
9431
|
page_context: "pageConsent",
|
|
9207
9432
|
browser_control: "controlConsent",
|
|
9433
|
+
commerce_cart: "commerceCartConsentDescription",
|
|
9208
9434
|
visual_context: "visualConsent",
|
|
9209
9435
|
handoff_context: "handoffConsent",
|
|
9210
9436
|
retained_transcript: "retentionConsent",
|
|
@@ -9213,6 +9439,7 @@ class WidgetView {
|
|
|
9213
9439
|
"microphone",
|
|
9214
9440
|
"page_context",
|
|
9215
9441
|
"browser_control",
|
|
9442
|
+
"commerce_cart",
|
|
9216
9443
|
"visual_context",
|
|
9217
9444
|
"handoff_context",
|
|
9218
9445
|
"retained_transcript",
|
|
@@ -9241,6 +9468,8 @@ class WidgetView {
|
|
|
9241
9468
|
const scopes = ["ai_disclosure", "text"];
|
|
9242
9469
|
if (this.recordingConsentOffered() && this.recordingConsent)
|
|
9243
9470
|
scopes.push("session_recording");
|
|
9471
|
+
if (this.commerceCartConsentOffered() && this.commerceCartConsent)
|
|
9472
|
+
scopes.push("commerce_cart");
|
|
9244
9473
|
if (required.has("page_context") &&
|
|
9245
9474
|
this.config.capabilities?.pageContext === true) {
|
|
9246
9475
|
scopes.push("page_context");
|
|
@@ -9258,6 +9487,7 @@ class WidgetView {
|
|
|
9258
9487
|
const shouldStageWelcome = mode === "text" && !initialQuestion && !this.welcomePresented;
|
|
9259
9488
|
if (shouldStageWelcome)
|
|
9260
9489
|
this.ensureWelcomeSkeleton();
|
|
9490
|
+
this.shoppingNotes?.prepareLaunch(initialQuestion);
|
|
9261
9491
|
const admitted = initialQuestion
|
|
9262
9492
|
? this.callbacks.onStart(mode, scopes, initialQuestion)
|
|
9263
9493
|
: this.callbacks.onStart(mode, scopes);
|
|
@@ -9390,6 +9620,7 @@ class WidgetView {
|
|
|
9390
9620
|
this.focusIntroControl(this.config.capabilities?.text === true ? "text" : "voice");
|
|
9391
9621
|
}
|
|
9392
9622
|
syncIntroMinimizedState() {
|
|
9623
|
+
this.renderCommerceCartConsent();
|
|
9393
9624
|
const entry = this.require('[data-role="intro-entry"]');
|
|
9394
9625
|
const frame = this.require('[data-role="intro-composer"]');
|
|
9395
9626
|
const composer = this.require(".intro-composer");
|
|
@@ -9533,12 +9764,18 @@ class WidgetView {
|
|
|
9533
9764
|
const value = this.currentConfirmation;
|
|
9534
9765
|
if (!value)
|
|
9535
9766
|
return false;
|
|
9536
|
-
if (Date.parse(value.expiresAt) <= Date.now()) {
|
|
9767
|
+
if (!Number.isFinite(Date.parse(value.expiresAt)) || Date.parse(value.expiresAt) <= Date.now()) {
|
|
9537
9768
|
this.confirmation.classList.remove("visible");
|
|
9538
9769
|
this.currentConfirmation = null;
|
|
9539
9770
|
this.dialogFocus.dismiss(this.confirmation);
|
|
9540
|
-
|
|
9541
|
-
|
|
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
|
+
}
|
|
9542
9779
|
return true;
|
|
9543
9780
|
}
|
|
9544
9781
|
this.confirmation.classList.remove("visible");
|
|
@@ -9546,7 +9783,13 @@ class WidgetView {
|
|
|
9546
9783
|
this.dialogFocus.dismiss(this.confirmation);
|
|
9547
9784
|
this.restoreVoicePresenceAfterPrompt();
|
|
9548
9785
|
this.syncHeaderActions();
|
|
9549
|
-
|
|
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);
|
|
9550
9793
|
return true;
|
|
9551
9794
|
}
|
|
9552
9795
|
restoreVoicePresenceAfterPrompt() {
|
|
@@ -9796,6 +10039,7 @@ class WidgetView {
|
|
|
9796
10039
|
}
|
|
9797
10040
|
presentContextPermissionDialog() {
|
|
9798
10041
|
this.restoreContextPermissionDialogAttributes();
|
|
10042
|
+
this.shoppingNotes?.close(false);
|
|
9799
10043
|
this.dialogFocus.present({
|
|
9800
10044
|
surface: this.visualRequest,
|
|
9801
10045
|
initialFocus: () => this.require('[data-role="visual-decline"]'),
|
|
@@ -9837,7 +10081,7 @@ class WidgetView {
|
|
|
9837
10081
|
currentSafetyIdentity(kind) {
|
|
9838
10082
|
if (kind === "confirmation") {
|
|
9839
10083
|
const value = this.currentConfirmation;
|
|
9840
|
-
return value ? `${value.actionId}:${value.proposalChecksum}` : null;
|
|
10084
|
+
return value ? `${value.onDecision ? "commerce" : "action"}:${value.actionId}:${value.proposalChecksum}` : null;
|
|
9841
10085
|
}
|
|
9842
10086
|
if (this.currentHandoffContextRequest) {
|
|
9843
10087
|
return `handoff:${this.currentHandoffContextRequest.requestId}:${this.currentHandoffContextRequest.requestChecksum}`;
|
|
@@ -10148,11 +10392,12 @@ class WidgetView {
|
|
|
10148
10392
|
this.writePanelVisibility("open");
|
|
10149
10393
|
this.syncLauncherState();
|
|
10150
10394
|
this.syncHeaderActions();
|
|
10151
|
-
requestAnimationFrame(() => this.clampPanelPosition());
|
|
10395
|
+
requestAnimationFrame(() => { this.clampPanelPosition(); this.commercePanel?.refreshVisibility(); });
|
|
10152
10396
|
if (!wasOpen && notifyOpen)
|
|
10153
10397
|
this.callbacks.onOpenChange?.(true);
|
|
10154
10398
|
}
|
|
10155
10399
|
closePanel() {
|
|
10400
|
+
this.shoppingNotes?.close(false);
|
|
10156
10401
|
if (!this.panel.classList.contains("open"))
|
|
10157
10402
|
return;
|
|
10158
10403
|
if (this.panel.classList.contains("ending-state")) {
|
|
@@ -10301,6 +10546,7 @@ class WidgetView {
|
|
|
10301
10546
|
if (!value)
|
|
10302
10547
|
this.panel.classList.remove("compact-text-arrived");
|
|
10303
10548
|
this.panel.classList.toggle("compact", this.compact);
|
|
10549
|
+
requestAnimationFrame(() => this.commercePanel?.refreshVisibility());
|
|
10304
10550
|
this.placeCtaOffer();
|
|
10305
10551
|
this.syncSurfaceEffectOwner();
|
|
10306
10552
|
if (persist && this.active && this.persistentState) {
|
|
@@ -11007,6 +11253,7 @@ class WidgetView {
|
|
|
11007
11253
|
this.stagedLaunchMode = null;
|
|
11008
11254
|
this.initialQuestionStaged = false;
|
|
11009
11255
|
this.active = false;
|
|
11256
|
+
this.commerceCartConsent = false;
|
|
11010
11257
|
this.endRequested = false;
|
|
11011
11258
|
if (this.paused)
|
|
11012
11259
|
this.setPaused(false);
|
|
@@ -11093,6 +11340,7 @@ class WidgetView {
|
|
|
11093
11340
|
}
|
|
11094
11341
|
const overlay = this.require('[data-role="legal-overlay"]');
|
|
11095
11342
|
overlay.hidden = false;
|
|
11343
|
+
this.shoppingNotes?.close(false);
|
|
11096
11344
|
this.dialogFocus.present({
|
|
11097
11345
|
surface: overlay,
|
|
11098
11346
|
initialFocus: () => this.require('[data-role="legal-close"]'),
|
|
@@ -11389,6 +11637,8 @@ class WidgetView {
|
|
|
11389
11637
|
this.restorePanelPosition();
|
|
11390
11638
|
}
|
|
11391
11639
|
syncHeaderActions() {
|
|
11640
|
+
this.syncShoppingNotesEntry();
|
|
11641
|
+
this.renderCommerceCartConsent();
|
|
11392
11642
|
this.panel.classList.toggle("active-session", this.active);
|
|
11393
11643
|
this.syncSessionModeUi();
|
|
11394
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;
|